Java Learning Made Easy by Dheeraj Mehrotra - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Program Using String Functions

02466.jpg02467.jpg02468.jpg

// Program to input a string and print the length of the string

02469.jpg

// In uppercase, in lowercase and in reverse.
class stringisc

02470.jpg

{

02471.jpg02472.jpg

public static void inputstring(String name)
{

02473.jpg02474.jpg

System.out.println("The entered string is "+name);
int len,words=0;

02475.jpg02476.jpg

len=name.length();

02477.jpg

System.out.println("The length of the string entered is "+len);

02478.jpg

System.out.println("The string in reverse is ");

02479.jpg

for(int i=len-1;i>=0;i--)

02480.jpg

System.out.print(name.charAt(i));

02481.jpg

// Printing the string in lower case

02482.jpg

System.out.println("The name in lowercase is ");

02483.jpg02484.jpg

System.out.print(name.toLowerCase());

02485.jpg02486.jpg

System.out.println("The name in uppercase is ");

02487.jpg02488.jpg

System.out.print(name.toUpperCase());

02489.jpg02490.jpg

}

02491.jpg02492.jpg

}

02493.jpg02494.jpg02495.jpgattention@computerscienceexpertise.com

 

02496.jpg02497.jpg02498.jpg02499.jpg02500.jpg02501.jpg02502.jpg02503.jpg02504.jpg02505.jpg02506.jpg02507.jpg02508.jpg02509.jpg02510.jpg02511.jpg02512.jpg02513.jpg