i want to diiscus my dobut with u.
i have some dobut i will be oblise if u will help me
my doubt is that can we make one class into another class n if it is posible than happend in folling case.
1 if i have nested calss then can i call method of iner most calss in outer most calss or can i do visvarsa.
2 what happend if i make outer class as public static void main(String a[ ]
3 what happend if i make outer most class in as public satatic void main (String a[]
i also want to do this problem by my oue but i have one problem i was using XP but due to viruses i fedup n i instole linux i never use linux before so i face many problems in instoling linux but i do it.n now i m working in linux but i can't instole it properly so i m facing probliems but still i want to work in linux so can u tell me how i can instole java in linux n how n where can i write my code .n also how i can compile n run that. due to this problem i cant do my practis.so i m looking for u r grat spourt plz guid me.i have also post some of my problems related to linux in from of this site i.t.
TECH TALK>LINUX AND UINX>I
ajay_tabbu
Junior Poster in Training
52 posts since Feb 2007
Reputation Points: 24
Solved Threads: 0
be more precise in your language use. Your writings are completely incomprehensible due to the volume of incorrect grammar and spelling.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
thanks for telling me this fact but my english is not good but i m working hard to improve it hope soon i will improve my language.again thanks for u r spout me to improv me.
plz tell me what ever i have posted in that u can understudied my problem or not if u can't then i will post that again in some batter way.
ajay_tabbu
Junior Poster in Training
52 posts since Feb 2007
Reputation Points: 24
Solved Threads: 0
2nd ponit is that if i if make any class as main class by public static void main then all the method of that class become static so in case of inner class if i make outer class as the main class then what happend with inner classes wether that class also become satatic or not.
3rd point is revers case of second that is waht happend if i make inner most class as main class then what happend with outer classes wether they become static or not.
ajay_tabbu
Junior Poster in Training
52 posts since Feb 2007
Reputation Points: 24
Solved Threads: 0
2nd ponit is that if i if make any class as main class by public static void main then all the method of that class become static so in case of inner class if i make outer class as the main class then what happend with inner classes wether that class also become satatic or not.
It is not as such compulsory to make the inner class as 'static' unless you plan on creating instances of that class in the 'outer class'.
But if you need to create instances of inner class, 'static' qualifier is the must:
public class Temp
{
public static class Inner
{
private int temp_ ;
public Inner ( int temp )
{
temp_ = temp ;
}
public Inner ( )
{
temp_ = 100 ;
}
public void main (String args [])
{
System.out.print ( "Helo Inner" ) ;
}
public int getValue ( )
{
return temp_ ;
}
}
public static void main (String args [])
{
Inner var1 = new Inner ( ) ;
System.out.println ( var1.getValue ( ) ) ;
Inner var2 = new Inner ( 999 ) ;
System.out.println ( var2.getValue ( ) ) ;
System.out.println ( "Helo" ) ;
}
}
3rd point is revers case of second that is waht happend if i make inner most class as main class then what happend with outer classes wether they become static or not.
You as such can't make your inner classes as the "main" class since inner classes can't have static declarations. The moment you try to do this the compiler will throw the above error. Take a look at this code:
// Temp.java
class A // you can't declare this as public since my filename is "Temp.java"
{
public static void main ( String[] args ) // won't be called since the main of only the
{ // public class with name same as file name will
// be called
System.out.print ( "Hello my friend" ) ;
}
public class Temp // inner class can never be the main class
{
private int temp_ ;
public static void main ( String[] args ) // error !!!
{
System.out.print ( "Hello my friend" ) ;
}
public Temp ( )
{
temp_ = 0 ;
}
public Temp ( int temp )
{
temp_ = temp ;
}
}
}
Oh and btw, those were good questions... ;)
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
It is not as such compulsory to make the inner class as 'static' unless you plan on creating instances of that class in the 'outer class'.
But if you need to create instances of inner class, 'static' qualifier is the must:
Not quite. In fact it's only mandatory when creating an instance from within a static method of the outer class.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337