In this program we will take string as an input and check its Lowercase letter and convert it into Uppercase letters and vice versa.In this topic we will take two examples in Example-1 we will convert string Letter into uppercase. And In Example-2 we will take string and will convert its letter into Lowercase letters.
Example-1 Converting to Lowercase String
Program Explanation
- Start
- Take String input
- String s1=sc.next();
- or Simply String s1=” NOTESHACKER”.
- Method to convert String into Lowercase
- s1.toLowercase;
- Print String s1;
- End
/*
Java Program to String intro Uppercase */
import java.util.*;
class Lowecase{
public static void main(String args[]){
System.out.println("Enter String-1");
Scanner sc=new Scanner(System.in);
String s1;
s1=sc.next();
System.out.println("Entered String Before Conversion:"+s1);
System.out.println("String in Lowercase:--"+ s1.toLowerCase());
}
}
Output:
Enter String-1
NOTESHACKER
Entered String Before Conversion:NOTESHACKER
String in Lowercase:--noteshacker
Example-2 Converting to Uppercase String
Program Explanation
- Start
- Take String inputString
- s1=sc.next();
- or Simply String s1=” noteshacker”.
- Method to convert String into Uppercase
- s1.toUppercase;
- Print String s1;
- End
/*
Java Program to String intro Uppercase */
import java.util.*;
class Lowecase{
public static void main(String args[]){
System.out.println("Enter String-1");
Scanner sc=new Scanner(System.in);
String s1;
s1=sc.next();
System.out.println("Entered String Before Conversion:"+s1);
System.out.println("String in Uppercase:--"+ s1.toUpperCase());
}
}
Output:
Enter String-1
noteshacker
Entered String Before Conversion:noteshacker
String in Uppercase:--NOTESHACKER
Related Topics
- Arithmetic Operations Java Program
- Java program to perform Logical and Relational operations
- Java program to Implement Mathematical functions defined in Java Math class
- Java basic Programs with Explanation
- Java Program to find Min,Max Element in an Array
- Java Program to sort Array Elements in ascending and descending order
- Java Program to display Array item at Even & Odd position
- Program to Calculate Sum and Average of Array elements
- Java Program to find Index of specific Element in an array
- Program to find common elements between two arrays
- Java Program to Add/Insert specific Element to an Array
- Java Program to delete specific element from an Array
- Program to calculate frequency of each element in Array
- Java Program to find Even and Odd Numbers in the arrays
- Java Program to search Given Number in an Array
- Java Program to Add or Sub Two Matrices
- Java Program to Multiply two or More Matrices
- Java Program to Print Array in Reverse Order
- Java Program To Transpose Given Matrix
- Java Programs List- Java Programs Examples With Output