Skip to main content

문자열 역순으로 출력

#


#

package pro_04_08;

 

import java.util.Scanner;

 

public class ReverseString {

 

public static void main(String[] args) {

// TODO Auto-generated method stub

String str;

int length;

int index;

char ch;

String rest;

String outputStr = "";

Scanner scan = new Scanner(System.in);

System.out.println("길이가 3인 문자열을 입력하세요 : ");

str = scan.next();

System.out.println("입력 문자열 : " + str);

length = str.length();

index = str.indexOf("");

ch = str.charAt(length-1);

rest = str.substring(1,length-1);

outputStr = str.substring(0, length-2);

//System.out.println("length : " + length);

//System.out.println("rest : " + rest);

//System.out.println("ch : " + ch);

//System.out.println("index : " + index);

//System.out.println("outputstr : " + outputStr);

 

System.out.println("출력 문자열 : " + ch + rest + outputStr );

 

 

}

 

}

 



#


Comments