80 likes | 234 Vues
This chapter delves into the fundamental differences between primitive types and classes in Java, emphasizing that classes like String start with a capital letter. Explore how methods such as length() are used to retrieve string lengths. It covers essential operators including comparison, increment, decrement, and arithmetic operations. Learn about casting, which converts data from one type to another, and the flow of control in sequences and nesting with if and if-else structures. Gain a better grasp of standard methods and their applications in Java programming.
E N D
Data Types, Data Structures and Constructs in Java Drew Bacha Chapter 2, 2.1.1-3
Beyond Primitives • The difference between a primitive and a class is that a class, String, starts with a capital letter. • length() is method that returns the current length of the string name.
Casting, Sequence, Nesting • Casting means converting from one data type to another. Placing the primitive type in front of the right hand side of an assignment. • Ex. int k = 450; • double x = k; // k gets converted to a double • A sequence of instructions is where statements or actions in an algorithm simply flow from one to the next. • Nesting occurs when one control variable(if and if else are control structures) is placed inside another.