Upcoming SlideShare
×

# Project Coinより小さなCoin

3,736 views

Published on

Published in: Technology, Education
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
3,736
On SlideShare
0
From Embeds
0
Number of Embeds
479
Actions
Shares
0
20
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Project Coinより小さなCoin

2. 2. Objects Short Long Integer Character Byte Boolean CollectionsAssertionError InetAddress ThrowableProcessBuilder Calendar
3. 3. Objects Short Long Integer Character Byte Boolean CollectionsAssertionError InetAddress ThrowableProcessBuilder Calendar
4. 4. Objectspublic static boolean equals(Object a, Object b)public static boolean deepEquals(Object a, Object b)public static int hashCode(Object o)public static int hash(Object... values)public static String toString(Object o)public static String toString(Object o, String nullDefault)public static <T> int compare(T a, T b, Comparator<? super T> c)public static <T> T requireNonNull(T obj)public static <T> T requireNonNull(T obj, String message)
5. 5. Objects#equalsObject o1 = new Object();Object o2 = o1;assert Objects.equals(o1, o2); // true// ==// false equals// return (a == b) || (a != null && a.equals(b))assert Objects.equals("aaa", "aaa"); // true
6. 6. Objects#deepEqualsint[][] a1 = { {1, 2, 3}, {4, 5, 6} };int[][] a2 = { {1, 2, 3}, {4, 5, 6} };// Arrays.deepEqualsassert Objects.deepEquals(a1, a2); // true
7. 7. Objects#toString// 2// String.valueOfString s1 = Objects.toString("aaa", "null value");assert s1.equals("aaa"); // trueString s2 = Objects.toString(null, "null value");assert s2.equals("null value"); // true
8. 8. Objects#requireNonNullvoid setName(String name) { // null this.name = Objects.requireNonNull(name, " ");}
9. 9. Objects Short Long Integer Character Byte Boolean CollectionsAssertionError InetAddress ThrowableProcessBuilder Calendar
10. 10. #compare // 0 x -1 // x 1java.lang.Short#compare(short x, short y)java.lang.Long#compare(long x, long y)java.lang.Integer#compare(int x, int y)java.lang.Character#compare(char x, char y)java.lang.Byte#compare(byte x, byte y)java.lang.Boolean#compare(boolean x, boolean y)
11. 11. Objects Short Long Integer Character Byte BooleanCollectionsAssertionError InetAddress ThrowableProcessBuilder Calendar
12. 12. Collectionspublic static <T> Iterator<T> emptyIterator()public static <T> ListIterator<T> emptyListIterator()public static <T> Enumeration<T> emptyEnumeration()
13. 13. // Iterator// Collections.emptyXXX()public Iterator<E> iterator() { if (data == null) { return Collections.emptyIterator(); } // ...}
14. 14. Objects Short Long Integer Character Byte Boolean CollectionsAssertionError InetAddress Throwable ProcessBuilder Calendar
15. 15. AssertionErrorpublic AssertionError(String message, Throwable cause)
16. 16. AssertionError(String, Throwable)try { Class.forName(" ");} catch (ClassNotFoundException e) { // try-catch // // throw new AssertionError(" (^o^) ", e);}
17. 17. Objects Short Long Integer Character Byte Boolean CollectionsAssertionErrorInetAddress ThrowableProcessBuilder Calendar
20. 20. Objects Short Long Integer Character Byte Boolean CollectionsAssertionError InetAddress ThrowableProcessBuilder Calendar
21. 21. Throwablepublic final synchronized void addSuppressed(Throwable exception)public final synchronized Throwable[] getSuppressed()
22. 22. Throwable#addSuppressedThrowable#getSuppressed// try-with-resources//try { view.setTimes(attrs.lastModifiedTime(), attrs.lastAccessTime(), attrs.creationTime());} catch (Throwable x) { // rollback try { Files.delete(target); } catch (Throwable suppressed) { x.addSuppressed(suppressed); } throw x;}
23. 23. Objects Short Long Integer Character Byte Boolean Collections AssertionError InetAddress ThrowableProcessBuilder Calendar
24. 24. ProcessBuilderpublic ProcessBuilder redirectInput(Redirect source)public ProcessBuilder redirectOutput(Redirect destination)public ProcessBuilder redirectError(Redirect destination)public ProcessBuilder redirectInput(File file)public ProcessBuilder redirectOutput(File file)public ProcessBuilder redirectError(File file)public ProcessBuilder redirectErrorStream (boolean redirectErrorStream)public ProcessBuilder inheritIO()public static abstract class Redirect
25. 25. //// md5 input.txt > output.txtProcessBuilder builder = new ProcessBuilder("md5");builder.redirectInput(Redirect.from(new File("input.txt")));builder.redirectOutput(Redirect.to(new File("output.txt")));Process process = builder.start();// ...
26. 26. Objects Short Long Integer Character Byte Boolean CollectionsAssertionError InetAddress ThrowableProcessBuilder Calendar
27. 27. Calendar (GregorianCalendar)public boolean isWeekDateSupported()public int getWeeksInWeekYear()public int getWeekYear()public void setWeekDate(int weekYear, int weekOfYear, int dayOfWeek)
28. 28. Calendar calendar = Calendar.getInstance();// ISO8601calendar.setFirstDayOfWeek(MONDAY);calendar.setMinimalDaysInFirstWeek(4);// 2011 1calendar.setWeekDate(2011, 1, MONDAY);assert calendar.get(YEAR) == 2011; // 2011assert calendar.get(MONTH) == 0; // 1assert calendar.get(DAY_OF_MONTH) == 3; // 3
29. 29. Calendar calendar = Calendar.getInstance();// ISO8601calendar.setFirstDayOfWeek(MONDAY);calendar.setMinimalDaysInFirstWeek(4);calendar.set(2011, 0, 2); // 2011 1 2assert calendar.getWeekYear() == 2010;calendar.set(2011, 0, 3); // 2011 1 3assert calendar.getWeekYear() == 2011;
30. 30. Calendar calendar = Calendar.getInstance();//ISO8601calendar.setFirstDayOfWeek(MONDAY);calendar.setMinimalDaysInFirstWeek(4);calendar.set(YEAR, 2011);assert calendar.getWeeksInWeekYear() == 52;calendar.set(YEAR, 2010);assert calendar.getWeeksInWeekYear() == 52;calendar.set(YEAR, 2009);assert calendar.getWeeksInWeekYear() == 53;