[Java] Java learning 2 (learn how to calculate)

less than 1 minute read

Article purpose

Since I decided to use Java in my work,
to output basic Java usage and organize my knowledge.

MyApp.java


public class MyApp{
   public static void main(String[] args){
    //Calculation
    int i;
    i = 10/3;
    System.out.println(i);
    i = 10% 3;
    System.out.println(i);
    int x = 5;
    x++;
    System.out.println(x);
    x--;
    System.out.println(x);
   }
}
$ javac MyApp.java
$ java MyApp
3
1
6
Five

MyApp.java


public class MyApp{
   public static void main(String[] args){
     //Calculation
     int x = 5;
     //x = x + 12;
     x += 12;
     System.out.println(x);
    
     String s;
     s = "hello" + "world!";
     System.out.println(s);
   }
}
$ javac MyApp.java
$ java MyApp
17
helloworld!

Tags:

Updated: