how to get a string in java code example

Example 1: How to split a string in Java

String string = "004-034556";
String[] parts = string.split("-");
String part1 = parts[0]; // 004
String part2 = parts[1]; // 034556

Example 2: string in java

In java, string is an object. It is sequence of character values enclosed by 
double quotes.

Example 3: how to reset a string in java

//Example string
String a = "Hello";

a = ""; //It's a simple way to reset/clear it, you can even put null instead of ""