Advertisement
lily09290110

基礎說明

Jan 18th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. package cc.openhome;
  2. import java.util.Scanner;//懶人包
  3. class c{
  4.     String color;
  5.     char size;
  6.     c(String color,char size) //建構式(constructor
  7.     {
  8.        this.color=color;
  9.        this.size=size;
  10.     }
  11. }
  12. public class Main{
  13.     public static void main(String[] args) {
  14.         Scanner com=new Scanner(System.in);//建立實例
  15.        final int pi=3;
  16.        final int a=75;
  17.        float b=3.14F;//遺失精準度問題,加f
  18.        long d=2147483648L;//int 2147489647
  19.        int num_scan;
  20.        num_scan=com.nextInt();//讀取指令操作
  21.        System.out.print(num_scan);
  22.        System.out.println();
  23.        c sun=new c("red",'s');
  24.         System.out.println("hello ");
  25.         System.out.printf("%d~%d\n",Integer.MIN_VALUE,Integer.MAX_VALUE);
  26.         System.out.println(pi);
  27.         System.out.println(a>70&&a<80);
  28.         System.out.printf("%d\n",d);
  29.         System.out.printf("%s,%c\n",sun.color,sun.size);
  30.     }  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement