Skip to content

Instantly share code, notes, and snippets.

View youngjinmo's full-sized avatar
👋
Hello world

Youngjin Mo youngjinmo

👋
Hello world
View GitHub Profile
@youngjinmo
youngjinmo / orderByinReverse.java
Created September 17, 2019 15:22
문자열 알파벳 역순으로 정렬하기
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];
}
@youngjinmo
youngjinmo / orderByAscii.java
Created September 17, 2019 15:12
문자열 알파벳 순서대로 정렬
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];
@youngjinmo
youngjinmo / deepToString.java
Created September 15, 2019 05:35
deepToString 예제
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]
@youngjinmo
youngjinmo / string2stringArray.java
Created September 15, 2019 05:34
String형 받아서 String형 배열로 변환하기
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]
@youngjinmo
youngjinmo / castingToInteger.java
Last active September 14, 2019 14:06
Integer형으로 형변환하는 방법
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
@youngjinmo
youngjinmo / castingToString.java
Last active September 16, 2019 09:59
String형으로 형변환 하는 방법
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
@youngjinmo
youngjinmo / tochar.java
Last active September 14, 2019 13:55
char형으로 형변환하는 방법
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
@youngjinmo
youngjinmo / todouble.java
Last active September 14, 2019 13:56
double형으로 형변환 하는 방법
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
@youngjinmo
youngjinmo / changeLetterByLetter.java
Last active September 11, 2019 10:26
문자열을 받아서 대문자는 소문자로, 소문자는 대문자로 바꾸는 메서드를 작성했다.
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();
@youngjinmo
youngjinmo / changeLetterByIndex.java
Last active September 11, 2019 10:36
문자열을 argument로 받아서 짝수번째 문자는 대문자로, 홀수번째 문자는 소문자로 바꾸어서 다시 문자열로 반환해보았다.
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 {
// 인덱스가 홀수인 문자를 소문자화