Variables are an integral part of any programming language. They are used to store data. Java, like many programming languages has different data types when defining variables. This code snippet shows two of the most common variable data types.
class SimpleVariables {
public static void main(String args[]) {
String name = "John";
int length = name.length();
System.out.println("My name " + name + " has " + length + " characters");
}
}
No comments:
Post a Comment