Java splitting based on comma

Java splitting based on comma

Program:

package com.ngdeveloper.com;
public class JavaSplitComma {
	public static void main(String[] args) {
		String input = "nokia,samsung,motorola,apple,lg,sony";
		String[] split = input.split(",");
		for(int i=0;i<split.length;i++){
			String output = split[i].toString();
			System.out.println(output);
		}
	}
}

 

Output:

nokia
samsung
motorola
apple
lg
sony

 

 

Thanks for reading this post……….!!!

488 total views, 1 views today

Leave a Reply

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