Skip to content

Instantly share code, notes, and snippets.

View ronsc's full-sized avatar

Ronnakorn Jannnalao ronsc

View GitHub Profile
@ronsc
ronsc / Test.java
Last active February 4, 2019 15:01
สรุป คร่าวๆ นะ SA => Entity Repository Controller ; spring boot jpa
/* ------ ใน 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;
@ronsc
ronsc / No3.java
Created December 23, 2013 05:40
ข้อสอบ Final 2/2556 ข้อที่ 3
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"));
@ronsc
ronsc / No2.java
Created December 23, 2013 05:27
ข้อสอบ Final 2/2556 ข้อที่ 2
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());
}
@ronsc
ronsc / Geek.java
Created December 23, 2013 05:13
ข้อสอบ Final 2/2556 ข้อที่ 1
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);
}
@ronsc
ronsc / Ex1.java
Created December 22, 2013 17:38
แบบฝึกหัดหน้า 153 ข้อ 1
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);
@ronsc
ronsc / Ex2.java
Created December 22, 2013 17:28
แบบฝึกหัดหน้า 154 ข้อ 2
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++){
@ronsc
ronsc / Ex4.java
Created December 22, 2013 17:15
แบบฝึกหัดหน้า 154 ข้อ 4
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"));
@ronsc
ronsc / Ex3.java
Created December 22, 2013 17:13
แบบฝึกหัดหน้า 154 ข้อ 3
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];
@ronsc
ronsc / Sample2.java
Created December 21, 2013 14:37
ข้อสอบข้อที่ 2 -------------------------------------------- ผลการรัน -------------------------------------------- 28802 4422682 15 45
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");
}
}
@ronsc
ronsc / AException.java
Created December 21, 2013 14:25
ข้อสอบข้อที่ 3 -------------------------------------------- ผลการรัน -------------------------------------------- suranaree : AException for Letter A korat : AException for Letter A ***sut*** ****good**** data : AException for Letter A
public class AException extends Exception{
public AException(String msg){
super(msg);
}
}