![]() |
|
[Java | Basic | 2] If Statements [Deviation] - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Design (https://sinister.li/Forum-Design) +--- Forum: Web Design (https://sinister.li/Forum-Web-Design) +--- Thread: [Java | Basic | 2] If Statements [Deviation] (/Thread-Java-Basic-2-If-Statements-Deviation) |
[Java | Basic | 2] If Statements [Deviation] - Crimin4L - 08-18-2013
Java Tutorial - If Statements
![]() By Bane, brought to you by Deviation Description: This is in no way the official description of If Statments, this is my description based on personal experience. If statments are used to check things, then react on the outcome. With If statements you can use booleans which we covered in the last tutorial. When programing, you make the code react to the person using the program. How To Setup/Use: When your coding Java, you will always use If Statements. This is how a If statement looks: PHP Code: if( Statement ){
}
Now, lets make it where a boolean controls the if statement PHP Code: public boolean name = true; //You have to declare it first before using it.
if(name){
}
Now if I wanted to a string say "Im on" when the boolean is true then you do this: PHP Code: public boolean name = true;
public String name2;
if(name){
name2 = "Im on";
}
System.out.println(name2);
PHP Code: public boolean name = true;
public String name2;
if(!name){
name2 = "Im off";
}
System.out.println(name2);
PHP Code: public boolean name = true;
public String name2;
if(name){
name2 = "Im on";
}else{
name2 = "Im off";
}
System.out.println(name2);
This is how I look at it. If name is on we will do this, anything else we will do this. 'This' meaning inside the brackets. There is a lot you can do with if statements, but that's all you need to know for now. You need to learn other basic stuff before we go into making a program together. From there I can go more into depth with booleans and if statements. Be sure to check my other tutorials! RE: [Java | Basic | 2] If Statements [Deviation] - OversouL - 08-18-2013 Thanks for the tutorials. I'm getting a lot of ideas about this
|