[ 작업 환경 ]
Windows10
jdk-15
1. StringMutation.java 실행
// 파일명 : StringMutation.java
//********************************************************************
// StringMutation.java Java Foundations
//
// Demonstrates the use of the String class and its methods.
//********************************************************************
public class StringMutation
{
//-----------------------------------------------------------------
// Prints a string and various mutations of it.
//-----------------------------------------------------------------
public static void main (String[] args)
{
String phrase = "Change is inevitable";
String mutation1, mutation2, mutation3, mutation4;
System.out.println ("Original string: \"" + phrase + "\"");
System.out.println ("Length of string: " + phrase.length());
mutation1 = phrase.concat (", except from vending machines.");
mutation2 = mutation1.toUpperCase();
mutation3 = mutation2.replace ('E', 'X');
mutation4 = mutation3.substring (3, 30);
// Print each mutated string
System.out.println ("Mutation #1: " + mutation1);
System.out.println ("Mutation #2: " + mutation2);
System.out.println ("Mutation #3: " + mutation3);
System.out.println ("Mutation #4: " + mutation4);
System.out.println ("Mutated length: " + mutation4.length());
}
}
추가로 substring (3, 30) 이기 때문에 index 3의 데이터부터 index 29 까지의 데이터가 남습니다.
C H A N G E
0 1 2 3 4 5
javac StringMutation.java
java StringMutation
'Development > Java' 카테고리의 다른 글
[Windows10][jdk15] 객체 지향 프로그래밍(OOP) Java 실습 04 - Garbage Collection 찾기 (0) | 2021.03.18 |
---|---|
[Windows10][jdk15] 객체 지향 프로그래밍(OOP) Java 실습 03 - Random 활용하기 (0) | 2021.03.18 |
[Windows10][jdk15] 객체 지향 프로그래밍(OOP) Java 실습 01 - Hello World! 출력하기 (0) | 2021.03.12 |
[Windows10][Java] jdk-15 최신 버전 설치 방법 (0) | 2021.03.11 |
[Windows10][open-jdk14] 실습 2 : 변수 & 주석 (0) | 2021.02.17 |