Advertisement
Guest User

java data types and scopes

a guest
Sep 19th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Hi{
  4.     public static void main(String[] args){
  5.         System.out.println("Hello, Javaworld!");
  6.         System.out.print("Goodbye!\n");
  7.         System.out.print("new line please");
  8.         System.out.println('[');
  9.         System.out.println(3);
  10.         System.out.println(3 + 3);
  11.         System.out.println(3 + "3");
  12.         byte x = -128;
  13.         // от -2^7 до 2^7 - 1 (-128 до 127)
  14.  
  15.         short y = 1;
  16.         // От -2^15 до 2^15 - 1
  17.  
  18.         int z = 1;
  19.         // от -2^31 до 2^31 - 1
  20.  
  21.         long c = 1;
  22.         // от -2^63 до 2^63 - 1
  23.  
  24.         System.out.println(x);
  25.         System.out.println(x - 1);
  26.  
  27.         y = (short)(x - 1);
  28.         System.out.println(y);
  29.  
  30.         x = 127;
  31.         z = (int)(x + 1);
  32.         System.out.println(z);
  33.  
  34.         x = (byte)z;
  35.         System.out.println(x);
  36.  
  37.         c = Long.MAX_VALUE;
  38.         // c = 10000000;
  39.         System.out.println(c);
  40.  
  41.         x = (byte)c;
  42.         System.out.println(x);
  43.  
  44.         String a = "Goodbye";
  45.         System.out.printf("We say %s %d times.%n Alt+F4", a, z);
  46.  
  47.         // javac Hi.java / java Hi
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement