This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes my code does not compile plz help me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "my code does not compile plz help me" Watch "my code does not compile plz help me" New topic
Author

my code does not compile plz help me

ganesh pol
Ranch Hand

Joined: Apr 29, 2005
Posts: 151
i hava Defined 2 classes
Test class in package test
A class in package A
code is given below

////////////////////////////////////////////////////
package test;
import A ;
public class Test
{
public static void main(String[] args)
{
A a = new A();
a.print("Hi");
System.out.println("Hello World!");
}
}

/////////////////////////////////////////
package A;
public class A

{
public static void main(String[] args)
{ String s1= "Ganesh";
Integer i1= new Integer(1);
System.out.println("Hello World!");
System.out.println(s1);
//System.out.println(new SimpleDateFormat("yyy mm dd"));
}

public void print(String s1) {
System.out.println(s1);
}
}

i have created object of class A in class Test but does not compile

class A Compiles but Test class in package test does not compile
ganesh pol
Ranch Hand

Joined: Apr 29, 2005
Posts: 151
note Both A and test are in a Same Folder
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

Package names should be lowercase; don't name your class the same name as a package.
Steve McCann
Ranch Hand

Joined: Oct 20, 2004
Posts: 81
Your files should be in different folders reflecting the package structure. Also, your import statement needs to be updated with either the class name or the * wildcard. Have a look at the Java Tutorial for more info on using packages etc.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I believe the above suggestions should help you figure out how to fix the problem. If not, please post the EXACT compiler error message along with some indication of which line each message refers to. This will help us tell you EXACTLY what is wrong without trying to guess what the problem is.

Layne


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: my code does not compile plz help me
 
Similar Threads
string problem
solve StringBuilder problem
System.out.Println with operator ==
:rolling: Innovative functions !!!
Package Compilation Problem