[JAVA] [CONVERT] 형변환
2021. 5. 14. 10:48
자바
String 형변환 String -> Int 형변환 String s = "1"; //string -> int 1번방식 int i = Integer.parseInt(s); //string -> int 2번방식 int i2 = Integer.valueOf(s); 1 1 String -> double 형변환 String s_num = "1"; //String -> Double 1번방식 double d_num = Double.parseDouble(s_num); //String -> Double 2번방식 double d_num2 = Double.valueOf(s_num); 1.0 1.0 String -> Float 형변환 String s_num = "1"; //String -> Float 1번방식 float f_..
[JAVA] String -> String[] 만들기
2021. 1. 22. 15:52
자바
String id = (String) params.get("id"); String[] delChkArray = id.split(","); for (int i = 0; i < delChkArray.length; i++) { System.out.println(delChkArray[i]); }
[JAVA] json -> map, map -> json 변환
2021. 1. 22. 15:48
자바
json -> map 변환 import com.fasterxml.jackson.databind.ObjectMapper; ObjectMapper mapper = new ObjectMapper(); Map map = mapper.readValue(jsonStr, Map.class); map -> json 변환 import com.fasterxml.jackson.databind.ObjectMapper; ObjectMapper mapper = new ObjectMapper(); String json = mapper.writeValueAsString(map); json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);