943,907 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1177
  • Java RSS
You are currently viewing page 1 of this multi-page discussion thread
Dec 14th, 2008
0

solve.java

Expand Post »
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...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
raija09 is offline Offline
5 posts
since Dec 2007
Dec 14th, 2008
0

Re: solve.java

What is "A"? You are trying to create an object of type "A", but from the code you have posted, no such class exists...
Reputation Points: 85
Solved Threads: 64
Practically a Master Poster
sillyboy is offline Offline
686 posts
since Mar 2007
Dec 15th, 2008
0

Re: solve.java

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
raija09 is offline Offline
5 posts
since Dec 2007
Dec 15th, 2008
0

Re: solve.java

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?
Reputation Points: 85
Solved Threads: 64
Practically a Master Poster
sillyboy is offline Offline
686 posts
since Mar 2007
Dec 15th, 2008
0

Re: solve.java

Quote ...
i got this code, unfortunately it refuses to run.. please help..
Something is wrong with "A", dnt know what it is...
Quote ...
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.
Featured Poster
Reputation Points: 653
Solved Threads: 151
Nearly a Posting Virtuoso
stephen84s is offline Offline
1,316 posts
since Jul 2007
Dec 16th, 2008
0

Re: solve.java

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
Reputation Points: 935
Solved Threads: 356
Nearly a Posting Maven
stultuske is offline Offline
2,497 posts
since Jan 2007
Dec 17th, 2008
0

Re: solve.java

Click to Expand / Collapse  Quote originally posted by stultuske ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
raija09 is offline Offline
5 posts
since Dec 2007
Dec 17th, 2008
0

Re: solve.java

Click to Expand / Collapse  Quote originally posted by stultuske ...
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....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
raija09 is offline Offline
5 posts
since Dec 2007
Dec 19th, 2008
0

Re: solve.java

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
awo
Reputation Points: 10
Solved Threads: 1
Newbie Poster
awo is offline Offline
21 posts
since Oct 2007
Dec 19th, 2008
0

Re: solve.java

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
awo
Reputation Points: 10
Solved Threads: 1
Newbie Poster
awo is offline Offline
21 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: nullpointerexception error
Next Thread in Java Forum Timeline: learning java





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC