This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes could someone help? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "could someone help?" Watch "could someone help?" New topic
Author

could someone help?

tom nugent
Ranch Hand

Joined: Dec 20, 2000
Posts: 32
Hello,
I am writing a snipet to see how to make callfromtest2()work, I ran into this runtime error "Exception in thread "main" java.lang.NoSuchMethodError: test2: method <init>(Ltest1 V not found
at test1.init(test1.java, Compiled Code)
at test1.<init>(test1.java:1)
at test1.main(test1.java:14)
"
Could someone tell me why this code didnt run? Also, where can I get additional explanation on the error msgs from jdk? Thank you.
==============

class test1 {
test2 t2;
Record record;

test1(){
record=new Record();
init();
}
public static void main(String[] args) {
test1 t1=new test1();

}
void init() {
t2=new test2(this);
record=new Record();
}
void callfromtest2() {
if(record.getName()=="Bush")
System.out.println("read done");
else System.out.println("ohoh");
}
}
class test2 {
int flag = 1;
test1 t1;
test2(test1 parent){
t1=parent;
method();
}
void method(){t1.callfromtest2();}
}
class Record {
String name = "Bush";
int term = 1;
String getName(){return name;}
}

[This message has been edited by tom nugent (edited March 07, 2001).]
Jyotsna Clarkin
Ranch Hand

Joined: Jan 26, 2001
Posts: 158

test10 t10;
Here you are declaring a reference t10 of type test10
but your code does NOT contain any such class defintion ?? Where is class test10 defined??
Should that line of code be
test1 t10 instead?
tom nugent
Ranch Hand

Joined: Dec 20, 2000
Posts: 32
You were right! I forgot to change the name to test1 from test10. Sorry about the confusion. I just re-edited and made corrections to the codes.

Siva Prasad
Ranch Hand

Joined: Feb 22, 2001
Posts: 104
Originally posted by tom nugent:
You were right! I forgot to change the name to test1 from test10. Sorry about the confusion. I just re-edited and made corrections to the codes.

Hi Tom
Still you are getting errors after running this program? You shouldnot!
usman ahmad
Ranch Hand

Joined: Mar 06, 2001
Posts: 46
Hi! This piece of code is working fine. i checked with it and it has no problems at all !!
it should be the same for you.
Regards Usman
tom nugent
Ranch Hand

Joined: Dec 20, 2000
Posts: 32
Yes, I still got the errors. This happened even after I re-installed the jdk1.3. My system is window2000. I don't know what's wrong. Any suggestions?
 
jQuery in Action, 2nd edition
 
subject: could someone help?
 
Similar Threads
Final Constructors?
I am getting clone() has protected access in java.lang.Object
cloning
method invocation
Private variable access