Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java Examples – Converting a String from Lowercase to Uppercase

Java Example – Convert string from lowercase to uppercase

Java Examples Java Examples

The following example uses the String toUpperCase() method to convert a string from lowercase to uppercase:

StringToUpperCaseEmp.java file

public

class

StringToUpperCaseEmp

{

public

static

void

main

(

String

[

]

args

)

{

String

str

=

"

string runoob

"

;

String

strUpper

=

str

.

toUpperCase

(

)

;

System

.

out

.

println

(

"

Original string:

"

str

)

;

System

.

out

.

println

(

"

Converted to uppercase:

"

strUpper

)

;

}

}

The output of the above code example is:



原始字符串: string runoob

转换为大写: STRING RUNOOB

Java Examples Java Examples