Just trying to figure out something really basic but not having any luck finding it on Google.
How do I implement an if...and...then type statement in Java?
Thanks.
Printable View
Just trying to figure out something really basic but not having any luck finding it on Google.
How do I implement an if...and...then type statement in Java?
Thanks.
For one line statments like that, you may omit the braces.Code:if ((x>0) && (x<=10))
{
System.out.println("x is between 0 and 10");
}
else
{
System.out.println("x is less than 0 or greater than 10");
}
Thanks very much, crptcblade! I knew it would be simple - but no wonder I couldn't find anything on Google...
Go to java.sun.com and then to their basic java tutorial. It teaches you all that.