Wednesday, 8 December 2021

Java Program to separate the Individual Characters from a String

separate

Java Program to separate the Individual Characters from a String

In this program, we need to separate each character from the string.
CHARACTERS

In computer science, collection of characters including spaces is called as string. To separate an individual character from the string, individual characters are accessed through its index.

string 1

CHARACTERS

string 2

C H A R A C T E R S

Program

class IndividualCharacters {

  public static void main(String[] args)   {

    //declare string

   String str1="characters ";

  System.out.println( "Individual characters from given string: " );

  for (int i = 0; i < string.length(); i++){

    System.out.print(string.charAt(i) + " ");

      }

   }

  }

output

Individual characters from given string:
c h a r a c t e r s

Theory

No comments:

Post a Comment

How do you select data from a table in SQL?

Create Table How do you select data a table in SQL? The SELECT statement is used to se...