aspose file tools*
The moose likes Beginning Java and the fly likes why not working System.out.println(c=a+b); Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why not working System.out.println(c=a+b);" Watch "why not working System.out.println(c=a+b);" New topic
Author

why not working System.out.println(c=a+b);

Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
why not working System.out.println(c=a+b);
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11229
    
  16

Ritesh raushan wrote:why not working System.out.println(c=a+b);

I guarantee you that the above line works. However, I would bet that it is not doing what you think it should, so unless you tell us what you think it should do, we can't help.

My GUESS - and this is nothing more than a guess - is that you meant to write



but I can't be sure. That may not work, since I don't know what types a, b, and c are. I could be completely wrong.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Heshan Fernando
Greenhorn

Joined: Nov 09, 2012
Posts: 2
I think that You may want to print "c=a+b" as a text,,,,,For that You have to make command this way,,,
System.out.println("c=a+b");

In this command,compiler get "c=a+b" as string data type and print c=a+b

otherwise if you want to print result of two numbers,,,you may have to assign values for a & b,,,and your source code should be this way,,,,
int a,b,c;
a=100;
b=200;
c=a+b;
System.out.println(c);
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
sorry it's working stranger type when i execute this code
my code asks from user but i have not write this type of code

output-enter two intgrs
12 34
46
do you want to continue(yes/n)
y//here if we write y or n code terminate

D:\sum>java Sum

this is my code

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38340
    
  23
That post doesn’t make sense. Do you want it to print the continuing question or not? Does it print the continuing question or not?
One way to get the continuing question is to use a do-while loop.
System.out.println(a + b); is probably preferable; the variable c is redundant in this instance.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Ritesh raushan wrote:sorry it's working stranger type when i execute this code
my code asks from user but i have not write this type of code


One of two things is happening:

1. You have a different class called Sum and your classpath is set so that it's picking up that class before the one you posted.

2. Your Sum class used to be written to do what you're seeing. You changed it, but you forgot to recompile.
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100
thanks jeff i got it Classpath problem.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

You're welcome. Glad you got it sorted out.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why not working System.out.println(c=a+b);