Lecture Notes
Lecture Notes
Camel case - Java follows the camel-case syntax for naming the classes, interfaces,
methods, and variables. If the name is combined with two words, the second word will
start with uppercase letter always, such as maxMarks( ), lastName, ClassTest, removing
all the whitespaces
Data types:
Examples:
Type Casting
• assign a value of one primitive data type to another type
• Applicable only to numerical datatype/ primitive data type
• Narrowing - casting a large type to a smaller type size. Narrowing casting must
be done manually by placing the type in parentheses in front of the value
double pi = 3.1416;
int a = (int) pi;
// System.out.println(a);
Examples:
String to integer
String s="200";
int i=Integer.parseInt(s);
Integer to string
it s= 200;
int i=String.valueOf (s);
Array methods:
To find out how many elements an array has, use the length