This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ------ ใน package .domain ------ */ | |
@Entity //@Entity ทำให้ public class Test {} เป็น Entity | |
public class Test { | |
@Id //กำหนดให้ Long id เป็น Primary Key | |
@GeneratedValue //กำหนดให้ id รันเลขไปอัตโนมัติ | |
private Long id; | |
@Column //สร้าง attribute ขื่อ name ชนิด String | |
private String name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class No3 { | |
public static void main(String[] args){ | |
ArrayList ar = new ArrayList(); | |
ar.add("hello"); | |
ar.add(new Integer(232)); | |
ar.add(new Boolean("true")); | |
ar.add(48); | |
ar.add(new Integer("8889888")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class No2 { | |
public static void main(String[] args){ | |
int[] num = {2, 4, 9, 81, 33, 48}; | |
for(int d : num){ | |
try { | |
process(d, num); | |
sumDigitFactorial(d); | |
} catch (SquareException ex) { | |
System.out.println(ex.getMessage()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Geek{ | |
public void process(String[] s, int n){ | |
int[] num = new int[s.length]; | |
int index = 0; | |
for(String d : s){ | |
for(int i = 0; i < d.length(); i++){ | |
char c = d.charAt(i); | |
if(Character.isDigit(c)){ | |
num[index] = num[index]*10 + (c - 48); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Ex1 { | |
public static void main(String[] args){ | |
String[] s = new String[] {"A2B3E4", "FF23", "AA4B2C3", "D14", "5AC"}; | |
ArrayList ar = new ArrayList(); | |
for(String d : s){ | |
int sum = 0; | |
for(int i = 0; i < d.length(); i++){ | |
char c = d.charAt(i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Ex2 { | |
public static void main(String[] args){ | |
String[] s = new String[] {"A23", "B343", "2C3", "X12", "MN2CD3Y"}; | |
TreeSet t = new TreeSet(); | |
for(String d : s){ | |
int val = 0; | |
for(int i = 0; i < d.length(); i++){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Ex4 { | |
public static void main(String[] args){ | |
ArrayList a = new ArrayList(); | |
a.add(3); | |
a.add(1.5); | |
a.add(new Student("John")); | |
a.add("Somsak"); | |
a.add(new Student("Jack")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Ex3 { | |
public static void main(String[] args){ | |
String[] s = new String[] {"A2B3E4", "FF23", "AA1B2C3", "D14", "5AC"}; | |
HashMap hm = new HashMap(); | |
int index = 0; | |
int[] key = new int[s.length]; | |
String[] value = new String[s.length]; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Sample2 { | |
public static void main(String[] args){ | |
Student s = new Student(); | |
s.doEven("235878021"); | |
s.doEven("4422136812"); | |
s.sum("12345"); | |
s.sum("9876543210"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AException extends Exception{ | |
public AException(String msg){ | |
super(msg); | |
} | |
} |