Separating a String into 4 Separate Strings

Posted on 2006-10-27
Last Modified: 2010-03-31
I have the following String...

String custInfo = "Timothy Woods; Toys'R'Us; 12345; 101 Victory Street, Columbus, Ohio 43230";

Can this be done in a quicker way than just declaring 4 Strings separately?

Thanks Everyone!
Question by:tristatefab

Accepted Solution

cpa199 earned 32 total points
ID: 17818130

Assisted Solution

colr__ earned 31 total points
ID: 17818230
String[] splitStrings = custInfo.split(";");

Assisted Solution

valipotor earned 31 total points
ID: 17818405
>>> Can this be done in a quicker way than just declaring 4 Strings separately?

As for execution time, declaring them as 4 separate strings it the fastest of them all.
LVL 86

Assisted Solution

CEHJ earned 31 total points
ID: 17818844
String[] custInfoAr = { "Timothy Woods", "Toys'R'Us",  "12345", "101 Victory Street",  "Columbus", "Ohio",  "43230" };

CustomerInfo ci = new CustomerInfo(custInfoAr); // make your own class for tis

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Fibonacci challenge 11 84
Books that can get me started on JAVA 2 56
countPairs challenge 7 58
Java asynchronous logging 4 35
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now