Advertisement
cgorrillaha

Untitled

Sep 8th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. class Main {
  2.   public static void main(String[] args) {
  3.    
  4.     //primitive types - simple, hold one piece of information, take one memory location
  5.     //Java is strictly typed
  6.     //int, double, boolean
  7.     //integer types
  8.     //byte - 8bit, short - 16, int - 32bit, long - 64bit
  9.     //float types
  10.     //float, double
  11.     //boolean
  12.     //char
  13.  
  14.     //Reference Types, or Object types
  15.     //String
  16.  
  17.     int num1, num2, sum;//declaration
  18.     String fName="Charlie",lName="Gorrill";//assignment
  19.     String fullName=fName+" "+lName;//concatenation
  20.     System.out.println(fullName);
  21.  
  22.     num1=15;//assignment statement or initialization
  23.     num2=27;
  24.     sum=num1+num2;//sum operation and assignment
  25.  
  26.   //p(cast)mdas
  27.     double average=0.0;
  28.     int num3, num4, num5, num6, num7;
  29.     num3=10;
  30.     num4=23;
  31.     num5=32;
  32.     num6=12;
  33.     num7=65;
  34.  
  35.  
  36.  
  37.     average=(double)(num3+num4+num5+num6+num7)/5;
  38.    
  39.  
  40.  
  41.     /*+++++++++++++++++++++++++++++++++++++++++++*/
  42.     /*++++++++++Plus Test Lab Here+++++++++++++++*/
  43.     /*+++++++++++++++++++++++++++++++++++++++++++*/
  44.     System.out.println ("This is a long string that is the " +
  45.                     "concatenation of two shorter strings.");
  46.  
  47.     System.out.println ("The first computer was invented about" + 55 +
  48.                     "years ago.");
  49.  
  50.     System.out.println ("8 plus 5 is " + 8 + 5);
  51.  
  52.     System.out.println ("8 plus 5 is " + (8 + 5));
  53.  
  54.     System.out.println (8 + 5 + " equals 8 plus 5.");
  55.  
  56.    
  57.   }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement