954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

solve.java

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...:(

raija09
Newbie Poster
5 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

What is "A"? You are trying to create an object of type "A", but from the code you have posted, no such class exists...

sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
 

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... :$

raija09
Newbie Poster
5 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

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?

sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
 
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.

stephen84s
Nearly a Posting Virtuoso
1,443 posts since Jul 2007
Reputation Points: 668
Solved Threads: 154
 

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

stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
 
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....

raija09
Newbie Poster
5 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 
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....

raija09
Newbie Poster
5 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

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

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

a more than obvious and useless answer: since the thread-starter had errors while running the code, it is safe to assume he/she has already figured out how to run a java app.

was it really necessary to post this twice?

stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
 

a more than obvious and useless answer: since the thread-starter had errors while running the code, it is safe to assume he/she has already figured out how to run a java app.

was it really necessary to post this twice?


Have you thought if he was executing the wrong code since there will be two classes. I he said he had problem with classes, now he has two class and one does not have a main method. What would happen if it was that particular one he was trying to execute
So pls think twice before you send your post

awo
Newbie Poster
21 posts since Oct 2007
Reputation Points: 10
Solved Threads: 1
 

then he would have gotten the obvious can not find main method error

stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
 

Chill Out Guys, the original poster has not posted since 4 days already

stephen84s
Nearly a Posting Virtuoso
1,443 posts since Jul 2007
Reputation Points: 668
Solved Threads: 154
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You