16 In August 2011 a car dealer is trying to deter mine how m
Solution
Java code showing a way to convert to uppercase
The first 2 lines of code simply got wind of a String variable to carry the text \"text to change\", then we tend to print it out. The third line sets of a second String variable referred to as result. The fourth line is wherever we tend to do the converting:
result = changeCase.toUpperCase( );
To use a string methodology you initially kind the string you wish to figure on. For us, this was the string within the variable referred to as changeCase. type A dot once the variable name and you will see an inventory of accessible strategies that you just will use on your string. choose toUpperCase. (The methodology wants the empty spherical brackets once it.)
After Java has modified the word to uppercase letters, we\'re storing the new string into our result variable.
When the program is run, the Output window displays the following:
Output of toUpperCase code
But you do not need to store the reborn word during a new variable. this may work even as well:
System.out.println( changeCase.toUpperCase( ) );
Here, Java can simply get on with changing the string, with no need to assign the result to a brand new variable.
If you wish to convert to small, simply use the toLowerCase methodology instead. it\'s employed in precisely the same means as toUpperCase.
In the next half, you will see a way to compare strings in Java.
