This file contains 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 quizTest_01 { | |
public static String changeByIndex(String str){ | |
String[] strArray = str.split(""); | |
for(int i=0; i<strArray.length; i++){ | |
// 인덱스가 0 또는 짝수인 문자를 대문자화 | |
if(i==0 || i%2==0){ | |
strArray[i] = strArray[i].toUpperCase(); | |
} else { | |
// 인덱스가 홀수인 문자를 소문자화 |
This file contains 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.Arrays; | |
public class quizTest_02 { | |
public static String changeByLetters(String str) { | |
String[] arr = str.split(""); | |
for (int i = 0; i <arr.length; i++) { | |
if(arr[i]==arr[i].toLowerCase()){ | |
// 문자가 소문자일 경우, 대문자로 변환 | |
arr[i] = arr[i].toUpperCase(); |
This file contains 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 toDouble { | |
public static void main(String[] args){ | |
int a = 66; | |
double b = 3.456; | |
String c = "90"; | |
char d = 'd'; | |
System.out.println("Integer to double : " + (double)a); | |
// Integer to double : 66.0 | |
This file contains 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 toChar { | |
public static void main(String[] args){ | |
int a = 66; | |
double b = 3.456; | |
String c = "90"; | |
char d = 'd'; | |
System.out.println("Integer to char : " + (char)a); | |
// Integer to char : B | |
This file contains 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 castingToString { | |
public static void main(String[] args){ | |
int a = 66; | |
double b = 3.456; | |
String c = "90"; | |
char d = 'd'; | |
System.out.println("Integer to String : " + String.valueOf(a)); | |
System.out.println("Integer to String : " + Integer.toString(a)); | |
// Integer to String : 66 |
This file contains 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 castingToInteger { | |
public static void main(String[] args){ | |
int a = 66; | |
double b = 3.456; | |
String c = "90"; | |
char d = 'd'; | |
System.out.println("Double to Integer : " + (int)b); | |
// Double to Integer : 3 | |
This file contains 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.Arrays; | |
public class str2strArray{ | |
public static void main(String[] args){ | |
String data = "Hello world"; | |
String[] strArray = data.split(""); | |
System.out.println(Arrays.toString(strArray)); | |
// [H, e, l, l, o, w, o, r, l, d] | |
This file contains 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.Arrays; | |
public class exampleCodes { | |
public static void main(String[] args){ | |
String data = "Hello world"; | |
String[] strArray_01 = data.split(""); | |
String[][] strArray_02 = {strArray_01, strArray_01}; | |
System.out.println(Arrays.toString(strArray_01)); | |
// [H, e, l, l, o, , w, o, r, l, d] |
This file contains 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.Arrays; | |
public class quizTest_03 { | |
public static String orderByAscii(String str){ | |
String[] temp = str.split(""); | |
Arrays.sort(temp); | |
String change = ""; | |
for (int i = 0; i < temp.length; i++) { | |
change += temp[i]; |
This file contains 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 orderByAsciiReverse { | |
public static String orderByinReverse(String str){ | |
String[] temp = str.split(""); | |
Arrays.sort(temp, Collections.reverseOrder()); | |
String changed = ""; | |
for (int i = 0; i < temp.length; i++) { | |
changed += temp[i]; | |
} | |