Skip to content

Commit 10efa40

Browse files
author
CodexRitik
committed
Basic Program to declare a variables in java.
1 parent 384d43f commit 10efa40

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/VariableTypes.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Test{
2+
int number = 100;//Instance Variable
3+
static int num = 50;//Class variable
4+
void display(){
5+
int sum;//Local Variable
6+
sum = number + num;
7+
System.out.println("Total Sum :"+sum);
8+
}
9+
}
10+
public class VariableTypes {
11+
public static void main(String[] args) {
12+
Test test = new Test();//Object creation
13+
test.display();//Method call
14+
}
15+
}

0 commit comments

Comments
 (0)