One public class must have one java file that is bottom line in Java. However, you can access another class within public class as you instatnciate the none public class using "new" keyword. The following is an example. import javax.swing.JFrame;
public class TestClass extends JFrame { public TestClass() { //some operation } public static void main(String[] args) { // TODO Auto-generated method stub test1 t1 = new test1(); System.out.println(t1.filed1); } } //here i can not able to give ny access specifier to this class //declaration. class test1 { String filed1 = "test1"; //some operation } Enjoy programming.... Chil --- On Thu, 12/2/10, Georgiana Filote <georg...@gmail.com> wrote: From: Georgiana Filote <georg...@gmail.com> Subject: Re: [java ee programming] can not able to give access specifer to class declaration To: santoshbjag...@gmail.com Cc: "Java EE (J2EE) Programming with Passion!" <java-ee-j2ee-programming-with-passion@googlegroups.com> Received: Thursday, December 2, 2010, 8:10 PM Hi, It's because in Java, for top-level classes(not inner/nested class) you can have for classes only default or public access level, so if you already have a public class in your file, you cannot declare another public class. Regards, Georgiana On Fri, Nov 26, 2010 at 8:42 AM, SantoshJ <santoshbjag...@gmail.com> wrote: hi, I am creating simple java program i.e. class file. I have written public class with main method to run that program. Also I have written another class into same java file. Here I can not able to give any access specifier to another class code block. Can any one explain me why this will be happen in java. Please find the java file code snapshot below: public class Test extends JFrame { public Test() { //some operation } public static void main(String[] args) { // TODO Auto-generated method stub } } // here i can not able to give ny access specifier to this class declaration. class test1 { //some operation } Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -- You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -- You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en