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

be more precise in your language use. Your writings are completely incomprehensible due to the volume of incorrect grammar and spelling.

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.

It's perfectly acceptable to have an inner class. You'll be able to access all the methods and instance variables of the inner class in your outer class. Now I'm not too sure about the reverse. I think that you'll be able to access all instance methods of the outer class in the inner class if they are declared above the inner class... now I also remember that things like that aren't an issue in Java so perhaps I'm mistaken.
I didn't quite understand points 2 and 3 I'm afraid.
Yes you can install Java on Linux... there are various ways to do it. Most Linux flavors come with Java support. Federa actually has Eclipse in it though I'm still a strong fan of Suse Linux :D
Well hope that helps.. I'll try the inner and outer class things and post a more certain reply if you don't get another.
Peace :)

commented: this post really help me. +1

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.

public class Outer {
 int instanceVariableOne;
 private class Inner {
  int a, b;
  public Inner(int x, int y)
  {
   instanceVariableOne = x;
   a = x * 2;
   instanceVariableTwo = y;
   b = y * 2;
  }
 }
 int instanceVariableTwo;
    
    public Outer()
    {
     Inner test = new Inner(1, 2);
     System.out.println("a from Inner\tb from Outer\n" + test.a + "\t\t\t\t" + test.b);
     System.out.println("\nOne\tTwo");
     System.out.println(instanceVariableOne + "\t" + instanceVariableTwo);
    }
    
    public static void main(String[]args)
    {
     new Outer();
    }
}

Hi, so I tested it out using the above code (which does nothing useful). It makes perfect sense and I can't believe I wasn't sure! What ever is declared within the same braces as your inner class will be accessible by the inner class regardless if it's declared private or public. The braces specify a scope. If something was declared in say the constructor of your outer class then it obviously won't be visible to the inner class - simply because anything delcared in a method is only visible in that method.
The inner class is always accessible to the outer class! If you declare the inner class private then it will not be accessible via a Outer class object though.
Oh and btw If you go to the Java site they give you instructions about setting it up with Linux :)

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... ;)

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.