On slide 16, we saw how to assign values to a variable of type String. Add to this example variables of type:
- double
- boolean
- int
assign values to them, and print them. For example, adding a boolean variable may look as follows:
class Hello4 { public static void main(String[] arguments) { String foo = "CST 1201"; System.out.println(foo); foo = "Something else"; System.out.println(foo); boolean isCold = false; System.out.println(isCold); isCold = true; System.out.println(isCold); } }
Upload your Hello4.java file to this assignment prior to the deadline. Please format your code prior to submission (make sure that all the statements line up and are indented properly; see the Java Language Coding Guidelines for more details). If you need help finding your file, please view the following YouTube video:
This material was created by Raffi Khatchadourian and published freely under a Creative Commons Attribution 4.0 license.