Upcoming SlideShare
×

# 変数の型 - Java 演習

461 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
Your message goes here
• Be the first to comment

• Be the first to like this

Views
Total views
461
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
3
0
Likes
0
Embeds 0
No embeds

No notes for slide

### 変数の型 - Java 演習

1. 1. 2011 10 3
2. 2. 2011 10 3
3. 3. 2011 10 3
4. 4. public class ListEvenNumbers { public static void main(String[] args) { //define limit int limit = 50; System.out.println("Printing Even numbers between 1 and " + limit); // i 1 50 for(int i=1; i <= limit; i++){ // ? ? // P37 if( i % 2 == 0) { System.out.print(i + " "); } } } } /* Output of List Even Numbers Java Example would be Printing Even numbers between 1 and 50 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 */2011 10 3
5. 5. 2011 10 3
6. 6. 0 -> 0000 0000 -> 00 1 -> 0000 0001 -> 01 2 -> 0000 0010 -> 02 3 -> 0000 0011 -> 03 4 -> 0000 0100 -> 04 5 -> 0000 0101 -> 05 6 -> 0000 0110 -> 06 7 -> 0000 0111 -> 07 8 -> 0000 1000 -> 08 9 -> 0000 1001 -> 09 10 -> 0000 1010 -> 0A 11 -> 0000 1011 -> 0B 12 -> 0000 1100 -> 0C 13 -> 0000 1101 -> 0D 14 -> 0000 1110 -> 0E 15 -> 0000 1111 -> 0F 16 -> 0001 0000 -> 102011 10 3
7. 7. 2011 10 3
8. 8. 2011 10 3
9. 9. 2011 10 3
10. 10. 2011 10 3
11. 11. 2011 10 3
12. 12. 2011 10 3
13. 13. 2011 10 3
14. 14. public class VariablesSample { public static void main(String[] args) { byte b; short s; int i; long l; char c; float f; double d; b = Byte.MIN_VALUE; s = Short.MIN_VALUE; i = Integer.MIN_VALUE; l = Long.MIN_VALUE; c = (int)Character.MIN_VALUE; f = Float.MIN_VALUE; d = Double.MIN_VALUE; System.out.println(b); System.out.println(s); System.out.println(i); System.out.println(l); System.out.println((int)c); System.out.println(f); System.out.println(d); } }2011 10 3
15. 15. 2011 10 3
16. 16. 2011 10 3
17. 17. public class BooleanSample { public static void main(String[] args) { boolean t = true; boolean f = false; if( t == true ){ System.out.println("t is true!"); }else{ System.out.println("t is false!"); } if( f == true ){ System.out.println("f is true!"); }else{ System.out.println("f is false!"); } boolean isTtrue = ( t == true); System.out.println("(t == true) is " + isTtrue); } }2011 10 3
18. 18. 2011 10 3