«

»

Aug 23

NetBeans Java Tutorial – If Statement and Variables #5

In this tutorial I show how to use different types of variables in Java as well as how to use a basic if statement.

Code:

package tutorials;
 
/**
 *
 * @author Edward
 */
public class Variables {
    public static void main(String args[]) {
        String myFirstVariable = "hi"; // Declaration and instantiation
        // Camel-case naming convention
 
        char myChar = 'd';
        int i = 3;
        double myDouble = 1.1;
        float myFloat = 1;
 
        if ((i * 2) != 2) { // True
            System.out.println("True!");
        } else { // False
            System.out.println("False!");
        }
    }
 
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>