-1
s.append("\n"); // new line
key = num[15]; // d 
s.append(line3.substring(key, key + 1));
key = num[17]; // r
s.append(line1.substring(key, key + 1));
key = num[4]; // o
s.append(line1.substring(key, key + 1));
key = num[2]; // n
s.append(line8.substring(key, key + 1));
key = num[1]; // e
s.append(line2.substring(key, key + 1));
s.append(" ");
key = num[0]; // B
s.append(line10.substring(key, key + 1));
key = num[1]; // E
s.append(line1.substring(key, key + 1));
key = num[0]; //T

I want to display the word B and E as uppercase characters. How do I do that?

4 Answers4

4

Just use the Character class' toUpper method.

Character.toUpper( 'b' ); //B

You can read more about the Character class and its other methods at the Javadoc

now this is only when working with the char's vs String's, so if you are doing String's I would go with Nicole's answer and use the corresponding String method as such:

s.append( line10.substring( key, key+1 ).toUpperCase() ); //B
Orin
  • 920
  • 5
  • 16
3

You can use this:

String str = "hello"; 
String strUpperCase = str.toUpperCase();
Gareth Davis
  • 27,701
  • 12
  • 73
  • 106
Nicole Phillips
  • 753
  • 1
  • 18
  • 41
0

This type of question has been answered already check this link. Or you can follow This link. Please do some research before asking the questions.

Community
  • 1
  • 1
0

There is a very complete response to your answer.

And I suggest to use .charAt function in place of .substring function for optimize your code.

Graham
  • 7,431
  • 18
  • 59
  • 84
Manuel Spigolon
  • 11,003
  • 5
  • 50
  • 73