int speed = 60;
Like I said in previous post integer variables can only hold whole values. In this example we assigned value of "60" to the variable "speed". Now if we print the value of "speed" to the terminal using the method learnt in the first post
System.out.println(speed);we'll see "60" as output on the terminal, or BlueJ console. 2. Using double
double weight = 65.5;
Let's say weight is 65.5 kilos. To represent this in a java program you can declare a double variable and assign the value to it.
System.out.println(weight);we'll see "65.5" as output on the terminal, or BlueJ console.
No comments:
Post a Comment