solve.java

Reply

Join Date: Dec 2007
Posts: 5
Reputation: raija09 is an unknown quantity at this point 
Solved Threads: 0
raija09's Avatar
raija09 raija09 is offline Offline
Newbie Poster

solve.java

 
0
  #1
Dec 14th, 2008
public class solve{
public static void main (String []args){
A cs = new A();
int first=34;
int second=4;
System.out.println("Sum:" + cs.add(first,second));
System.out.println("Difference:" + cs.subtract(first,second));
}
}


i got this code, unfortunately it refuses to run.. please help..
Something is wrong with "A", dnt know what it is...
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: solve.java

 
0
  #2
Dec 14th, 2008
What is "A"? You are trying to create an object of type "A", but from the code you have posted, no such class exists...
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 5
Reputation: raija09 is an unknown quantity at this point 
Solved Threads: 0
raija09's Avatar
raija09 raija09 is offline Offline
Newbie Poster

Re: solve.java

 
0
  #3
Dec 15th, 2008
im not really good in making classes.. some gave this to me but i don't fully understand...

this is the code i guess...

public class Greeting{
private String Salutation;

Greeting (String s){
Salutation = s;
}

public void greet (String whom){
System.out.println (Salutation + " " + whom);
}
}


together with this one...

public class TestGreeting{

public static void main (String[] args){

Greeting Hello = new Greeting ("Hello");

Hello.greet ("World!");
}
}


please help me on this... tnx...
Last edited by raija09; Dec 15th, 2008 at 1:40 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 686
Reputation: sillyboy is on a distinguished road 
Solved Threads: 61
sillyboy's Avatar
sillyboy sillyboy is offline Offline
Practically a Master Poster

Re: solve.java

 
0
  #4
Dec 15th, 2008
Is there a problem with that second example?

It looks unrelated to your original post, what exactly do you need me to help you with?
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,175
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is online now Online
Veteran Poster

Re: solve.java

 
0
  #5
Dec 15th, 2008
i got this code, unfortunately it refuses to run.. please help..
Something is wrong with "A", dnt know what it is...
im not really good in making classes.. some gave this to me but i don't fully understand...

this is the code i guess...
Now how are we supposed to help you on this information given by you ???
If you are not good at creating classes, I recommend you purchase a good book like "Head First Java" or something similar which till teach you object oriented programming along with Java.
Also the "Starting Java" thread at the top as the name suggests has been created specifically for users like yourself who are just begining to do programming.

Also asking questions like the one above and asking us to fix it will only make you more dependent on others to get your work done and if you intend making a career in this field, I am pretty sure you do not want that.
Last edited by stephen84s; Dec 15th, 2008 at 3:35 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: solve.java

 
0
  #6
Dec 16th, 2008
propably the wrong part is that you do not have a class A, so you're trying to instantiate and use an object type that doesn't exist.
create the class and try it again
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 5
Reputation: raija09 is an unknown quantity at this point 
Solved Threads: 0
raija09's Avatar
raija09 raija09 is offline Offline
Newbie Poster

Re: solve.java

 
0
  #7
Dec 17th, 2008
Originally Posted by stultuske View Post
propably the wrong part is that you do not have a class A, so you're trying to instantiate and use an object type that doesn't exist.
create the class and try it again


thanks anyway, and Advance Merry Christmas....
Last edited by raija09; Dec 17th, 2008 at 9:58 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 5
Reputation: raija09 is an unknown quantity at this point 
Solved Threads: 0
raija09's Avatar
raija09 raija09 is offline Offline
Newbie Poster

Re: solve.java

 
0
  #8
Dec 17th, 2008
Originally Posted by stultuske View Post
propably the wrong part is that you do not have a class A, so you're trying to instantiate and use an object type that doesn't exist.
create the class and try it again

ok i'll try....
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 15
Reputation: awo is an unknown quantity at this point 
Solved Threads: 1
awo's Avatar
awo awo is offline Offline
Newbie Poster

Re: solve.java

 
0
  #9
Dec 19th, 2008
the second problem seems to be ok by me
to run the code simply use
javac TestGreeting.java
then
java TestGreeting
it should run with out any problem
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 15
Reputation: awo is an unknown quantity at this point 
Solved Threads: 1
awo's Avatar
awo awo is offline Offline
Newbie Poster

Re: solve.java

 
0
  #10
Dec 19th, 2008
the second problem seems to be ok by me
to run the code simply use
javac TestGreeting.java
then
java TestGreeting
it should run with out any problem
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC