Java Data Types and Variables

Variables in Java:

String myString = “Hello”;

int coolNumber = 555;

double decimalNum = 3.52;

Java’s split() method:

public class Main{

public static void main(String[] args){

String listOfNames = “alice bob chris diana eric fred”;

String[] nameArray = listOfNames.split(” “);

for (int i = 0; i < nameArray.length; i++) {

System.out.println(nameArray[i]);

}

}

}

Constants in Java:

final int WIDTH = 1920;

Type casting in Java:

String notAnInt = “5”;

int isAnInt = 123;

System.out.println(isAnInt + Integer.parseInt(notAnInt));

← Previous | Next →

Java Topic List

Main Topic List

Leave a Reply

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