Monday, 12 August 2013

Enter String Without Using Functions

Strings are a sequence of characters. In the Java programming language, strings are objects.In string the objects are created two ways:


  • Using string literal.
  • Using new keyword.


WAP to enter strings in java without using any function

class strings{
public static void main(String args[])
{
char ch[]={'s','i','n','g','h'};           //Entered words character by character 
String s1="Maninder singh";        //Entered words in string
String s2=new String(s1);           //String object created using new keyword
System.out.println(s2+"\n");
System.out.println(s1+"\n");        //String used using string literal
System.out.println(ch);

}
}

Output of the program:

String In java



Like the Post? Do share with your Friends.

No comments:

Post a Comment

IconIconIconFollow Me on Pinterest

Blogger news

Blogroll

What's Hot