public void test(int x)
{
int odd = 1;
if(odd) // if i write odd==1 it works but i have used this in C a number of times.
{
System.out.println("odd");
}
else
{
System.out.println("even");//output compilation error
}
}
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
public void test(int x)
{
int odd = 1;
if(odd) // if i write odd==1 it works but i have used this in C a number of times.
{
System.out.println("odd");
}
else
{
System.out.println("even");//output compilation error
}
}
Last edited by Dark knight; July 19th, 2012 at 03:00 AM.
This is a double post of an already active question: http://www.javaprogrammingforums.com...html#post71106
If I were a moderator on this forum, I'd close this thread and chastise you for needlessly splitting up a discussion. Perhaps you didn't mean to ask this question in two places? You should probably state in both of these threads which one is the active one so as not to mislead anyone.
Last edited by Fubarable; July 19th, 2012 at 12:28 AM.
ohk sorry my bad!!!!! i was going to ask a different question accidentally copy pasted this one...
When I was a tadpole (on a medium-sized water planet in a galaxy far, far away) the teacher made us write things 100 times on our (underwater) blackboard.
With modern Earth technology, it is a little easier:
Output:
In spite of some syntactical similarity: Java is not C. Lots of stuff that works in C is totally bogus Java!
In spite of some syntactical similarity: Java is not C. Lots of stuff that works in C is totally bogus Java!
In spite of some syntactical similarity: Java is not C. Lots of stuff that works in C is totally bogus Java!
.
.
.
Bottom line (in case you missed it): Java is not C.
And, while you are at it, try to imagine how a tadpole can write anything. (Ouch!)
School was a lot tougher way back when.
Cheers!
Z
Last edited by Zaphod_b; July 19th, 2012 at 09:35 AM.
Dark knight (July 19th, 2012)