Menu

Beanzilla

Never give up, Never surrender

Java Essentials: Data Types, Variables.

String, int, boolean, double All of them are data types, which as many call variables.

The code below shows basic mathmatics including Strings.

To run on your own machine to see the results, (Reccomend installing BlueJ) then copy and compile then Right click and select "void Main()".

Create a new file and copy the code below.

/**
 * @author Beanzilla

 * @version 1.02

 */

public class DataTypes

{

    public static void Main()

    {

        String word = "This is a String";                 // Characters in the alphabet, can also include

                                                                          // numbers inside the "".

        int number = 9;                                          // not equal to 9.0.

       double number2 = 1.0;                               // not equal to 1. Could not use float as it is a Java real

                                                                          // word.

       boolean witch = True;                                // Couldn't use switch as it is a Java reserved word.

       System.out.println("String: " + word);

       System.out.println("Integer: " + number);

       System.out.println("Double / Float: " + number2);

       System.out.println("Boolean: " + witch)

    } // End of Method

} // End of Class

Written by Bzy on Sunday November 13, 2016

Permalink -

« Java Essentials: Print, Print new line, Print a variable, Print plus variable. - Hordes.io »

Related content