Java Program to insert space between every Characters

Get a String and Prints it characters with Space

Sample Input 1:

Hello

Sample Output 1:

H e l l o

Try your Solution

Strongly recommended to Solve it on your own, Don't directly go to the solution given below.

public class Hello { public static void main(String args[]) { //Write your code here } }

Program or Solution

				
			
					
//Print The Character Of String With Space...

import java.util.*;

class Program
{
 public static void main(String args[])
  {
     String word;
     Scanner sc=new Scanner(System.in);

     System.out.println("Enter The Word:");  
     word=sc.nextLine();  

     int len1=word.length();
     int i;

     System.out.println("The Output Is:");
     for(i=0;i<len1;i++)
       {
            System.out.println(" "+word.charAt(i));
            System.out.println(" ");
       }

  }
}
			
				
			

Program Explanation

Comments