Now you have a rough idea about the Data Types. So now it's time for a simple calculation.
We know numeric values can be used in 'int' data type ant texts in 'String'.
Okay let's go...
- Open Eclipse
- File > New > Java Project
- Type a project name
- Right click 'src'
- New > Class
- Give it a name
Now it's for the coding
public class main {
public static void main(String []args){
int total;
int x = 20 ;
int y = 10 ;
total = x+y ;
System.out.println(total);
}
}
Let's Print a name
public class main {
public static void main(String []args){
String fname = "David" ;
String sname = "Miller";
String fullname = fname + sname ;
System.out.println(fullname);
}
}
No comments:
Post a Comment