String Handling: Introduction

In this blog, we will see introduction about String Handling process, currently we will just see how store value in String object.

For that, we use object passing, character array, byte array etc.

This topic is very easy then other java topics.

 

Let’s see String handling introduction example

 

class str1

{

                public static void main(String args[])

                {

                                String str1 = “Welcome in Java String”;

                                System.out.println(str1);

 

                                String str2 = str1;              // Process 1

                                String str3 = new String(str1);     // Process2

                                System.out.println(str2);

                                System.out.println(str3);

 

                                char ch[] = {‘H’,’e’,’l’,’l’,’o’,’ ‘,’J’,’a’,’v’,’a’};

                                String str4 = new String(ch);        // also pass character array in string

                                System.out.println(str4);

 

                                String str5 = new String(ch,2,5); // 2-start index, 5-width of string | 5 character

                                System.out.println(str5);

 

                                byte b[] = {65,78,90,63,79};

 

                                String str6 = new String(b,1,3);   // 1 – start index , 3 – no of characters

                                System.out.println(str6);             

                }

}

Output:

Welcome in Java String

Welcome in Java String

Welcome in Java String

Hello Java

ll J

NZ?

 


Video available on YouTube.


[sbscrbr_form]

If you have any query on blog example, you can directly comment us or subscribe our website


Earn Money Online

916total visits,4visits today


mayank

Hello, I am Maddy a Java blogger, trainer and developer

Related articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Your comments (*)

Name (*)

Your full name please.

Email address (*)

Used for gravatar.

Website

Link back if you want.

Enter Captcha Here :*

Reload Image