Convert input string into Uppercase

Convert Input string into Uppercase

 There are many built-in classes in the Java programming language. 'String', 'Scanner', 'Math' are some of out of all the built-in classes inside the Java programming language. And here you need 'String' class to convert the input string into Uppercase which is present inside the 'lang' package of the 'java' project.
All the built-in classes in Java contain many methods which are helpful to perform the mentioned specific task. So to convert the inputted string into uppercase you need to call toUpperCase() method from the String class. And is done by the keyword called  'import'.

import java.lang.String; //Importing String class from lang package
import java.util.Scanner; //Importing Scanner class from util package

public class StringToUC
{
    public static void main(String []args)
    {
         String str1; //Declaring Variables

         System.out.println("Enter String"); //Instruction to user to input string
         str1= new Scanner(System.in).nextLine(); //Getting string from keyboard

         String str=str1.toUpperCase()//Processing value to UpperCase 
         System.out.println("The String in uppercase is "+str); //Printing Result
    }
 }


Output of this program looks like this

Enter String
qwerty The String in uppercase is QWERTY

Comments

Popular posts from this blog

Java program using Scanner Class

Java Program to make a comparison between numbers

Calculate the area of Rectangle Using Constructor Overloading rules