fred rosenberger wrote:if neither class has a package statement, they are both in what's called the 'default package'.
Bear Bibeault wrote.
John Jai wrote:Try this...
This is class #1
package cert;
public class Roo {
public String doRooThings() {
// imagine the fun code that goes here
return "fun";
}
}
This is class #2... you got to make a class public to invoke the main method though
package notcert; //Not the package Roo is in
import cert.Roo;
class Cloo extends Roo {
public void testCloo() {
System.out.println(doRooThings());
}
}
class Toon {
public static void main(String[] args) {
Cloo c = new Cloo();
System.out.println(c.doRooThings()); //No problem; method
// is public
}
}
but i have not gone through that page... just a guess..
i don't think you are right how you can assume that two classes is single class ,have you ever seen anywhere this logic?,
John Jai wrote:Ok... lets go this way...
Have the two classes I put up like below...
cert\Roo.java - where cert is the package name
notcert\SomeClass.java - where notcert is the package name and SomeClass.java is the java FILE that holds the two classes Cloo and Toon...
now open a cmd prompt... compile Roo.java and SomeClass.java... you will have three class files... Roo.class, Cloo.class, Toon.class...
Run the Toon class by using the command -> java notcert.Toon ... did you see any output??
i don't think you are right how you can assume that two classes is single class ,have you ever seen anywhere this logic?,
I use more than a class when needed in the same java FILE...
what is meaning of unworkable code in book....
how to make these nonsense classes workable
John Jai wrote:
in my humble opinion any code that compiles fine is workable...
you are right but Toon class generates compile error that can't find Cloo symbol.
Cloo c = new Cloo();
Are you using an IDE like Eclipse rather than a text editor and cmd prompt?
I am beginner so i don't use any IDE, i am using notpad and cmd.
in my humble opinion any code that compiles fine is workable...
Are you using an IDE like Eclipse rather than a text editor and cmd prompt?
John Jai wrote:Good... and in future please use UseOneThreadPerQuestion
Chiranjeevi Kanthraj wrote:Congrtas