-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLesson1Variables.java
More file actions
58 lines (43 loc) · 1.97 KB
/
Lesson1Variables.java
File metadata and controls
58 lines (43 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Lesson1Variables {
public static void main (String [] args){
// variables in java
/*
two main branches ie. primitive and reference variables
primitive => stored directly in memory (stack)
they include boolean- //can only contain true or false
char -16bits char single characters surrounded by single quote
byte- 8 bits
short 16bits
int 32bits integers , contain whole numbers
long 64bits
float 32bits
double 64bits numbers but can contain a decimal
reference - store memory address to that points to the heap
they include: strings=>series of characters surrounded by double quotes
array
objects
*/
// declaring a variable
int age;
// assigning a value
age=10;
char grade ='A';
boolean isStudent= true;
double price= 19999.99;
char currency ='$';
System.out.println(age);
System.out.println(grade);
System.out.println(isStudent);
//strings
System.out.println("Strings");
String name=" John muriungi ";
String email="funny@342@gmail.com";
String color="red";
/////////////////////////////////////////////
System.out.println(name);
System.out.println("hello "+name);//cocantenation
System.out.println("hello "+name+" you are "+age+ " years old");
}
}