物件導向程式設計

 

 

      2.6 整數運算

 

 


授課教師:陳慶瀚

WWW : http://www.miat.ee.isu.edu.tw/java

E-mail : pierre@isu.edu.tw   

 


class AddInts 
{
  public static void main (String args[]) 
  {
 
    int i = 1;
    int j = 2;
    int k;
 
    System.out.println("i is " + i);
    System.out.println("j is " + j);
  
    k = i + j;
    System.out.println("i + j is " + k);
    
    k = i - j;
    System.out.println("i - j is " + k);
  }
} 
Here's what happens when you run AddInts:
C:\> javac AddInts.java
C:\> java AddInts
i is 1
j is 2
i + j is 3
i - j is -1
C:\>

 


 

物件導向程式設計

義守大學電機系 陳慶瀚

2001.10.02