String Methods

Write a program to show different strings methods.

 

import java.util.Scanner; class P06StringMethods { public static void main(String args[]) { String name; System.out.println("Enter your name"); Scanner in = new Scanner(System.in);//object of scanner class is in. name = in.next(); System.out.println("YOUR NAME IN UPPER CASE " +name.toUpperCase()); System.out.println("\n your name in lower case " +name.toLowerCase()); System.out.println("\n Third Character is " +name.charAt(2)); System.out.println("\n Numberof letters in your name " +name.length()); System.out.println("\n Position of Letter j " +(name.indexOf('j')+1)); System.out.println("\n Given name ends with "+name.endsWith("t"));//return boolean } }



For any desired program, please comment below. We will try our best to make that program available.


Comments

Popular Posts