Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Contructor methods not being called

Contructor methods not being called

Put your problem here if it does not fit any of the other categories.

Contructor methods not being called

Postby Schermvlieger » Fri Mar 19, 2010 9:28 am

Hi guys/gals,

I am so sorry to post this here, but i am really stumped and don't know where else to ask. I have read and reread the parts about creating and instantiating classes on http://java.sun.com/docs/books/tutorial/index.html but it looks like I am doing it right. I am new to this programming language though.

The problem:

The constructor methods of my inner classes are not being called. Is this something Android specific? I cannot find anything about that in the Dev Guide, and it seems rather unlikely that this is intentional behavour.

This is the relevant part of the code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. public class MyActivity extends Activity {
  5.  
  6. Thing mything;
  7.  
  8. public void onCreate(Bundle savedInstanceState) {
  9.  
  10. mything = this.new Thing()
  11.  
  12. }
  13.  
  14. private class Thing {
  15.  
  16. public void Thing() {
  17.  
  18. // initializing stuff here
  19.  
  20. }
  21.  
  22. }
  23.  
  24. }
  25.  
  26.  
  27.  
  28.  
Parsed in 0.016 seconds, using GeSHi 1.0.8.4


When I run this code, the constructor method of mything is not executed. I have to place an explicit call to Thing() in OnCreate to have my initialization code to run. What am i doing wrong here?
Schermvlieger
Senior Developer
Senior Developer
 
Posts: 159
Joined: Fri Feb 26, 2010 1:37 pm

Top

Re: Contructor methods not being called

Postby pskink » Fri Mar 19, 2010 9:45 am

Schermvlieger wrote:This is the relevant part of the code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class MyActivity extends Activity {
  3. Thing mything;
  4. public void onCreate(Bundle savedInstanceState) {
  5. mything = this.new Thing()
  6. }
  7. private class Thing {
  8. public void Thing() {
  9. // initializing stuff here
  10. }
  11. }
  12. }
  13.  
  14.  
Parsed in 0.010 seconds, using GeSHi 1.0.8.4


When I run this code, the constructor method of mything is not executed. I have to place an explicit call to Thing() in OnCreate to have my initialization code to run. What am i doing wrong here?


create constructor without void


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. private class Thing {
  5.  
  6.         public Thing() {
  7.  
  8.                 // initializing stuff here
  9.  
  10.         }
  11.  
  12. }
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
Parsed in 0.010 seconds, using GeSHi 1.0.8.4
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Postby Schermvlieger » Fri Mar 19, 2010 10:08 am

Thanks pskink!

So typical of me to overlook these little errors when I lack routine in something >.<
Schermvlieger
Senior Developer
Senior Developer
 
Posts: 159
Joined: Fri Feb 26, 2010 1:37 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests