Thursday, March 31, 2016

Using int and String


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...

  1. Open Eclipse
  2. File >  New > Java Project 
  3. Type a project name
  4. Right click 'src'
  5. New > Class
  6. 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