| | |
arrays and strings
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
a String is one Object (of the type String). an array is a small collection of Objects.
for instance: you know you need to keep seven String-Objects, containing the days of the week, in your program.
String dayOne = "Monday";
String dayTwo = "Tuesday";
...
like here above, this are seperate Objects of the type String.
if you would use:
String week[] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
then, you have one array, containing seven String Objects.
now you can use:
dayOne = week[0];
=> this will load the first element of the array into the variable with the name dayOne.
for instance: you know you need to keep seven String-Objects, containing the days of the week, in your program.
String dayOne = "Monday";
String dayTwo = "Tuesday";
...
like here above, this are seperate Objects of the type String.
if you would use:
String week[] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
then, you have one array, containing seven String Objects.
now you can use:
dayOne = week[0];
=> this will load the first element of the array into the variable with the name dayOne.
•
•
Join Date: May 2007
Posts: 8
Reputation:
Solved Threads: 1
•
•
•
•
Strings aren't arrays, arrays aren't strings.
What's the difference between a basketball and a barbequeue?
Maybe you meant what is the difference between a Variable and an Array?
Because essentially an Array is a variable, which can contain a multiple number of expressions.
But, to answer what you're asking, a String is like a sentence, for example:
"This is a string."
An Array is exactly what I stated above, it's a variable that contain multiple numeric values, or technically I guess it could be used to store anything, and more than one!
For example:
Normal Variable -
Java Syntax (Toggle Plain Text)
int X = 10;
Java Syntax (Toggle Plain Text)
int X[3]
Maybe you saw something like this:
String months[] =
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"July", "Aug", "Sep", "Oct", "Nov", "Dec"};And it confused you possibly?
![]() |
Similar Threads
- C help to newbie (C)
- Unsorted List ADT Client Code Help (C++)
- need debugging help.. i've look at this too long (C++)
- Check digit (C++)
- help!! about ADT list please (C)
- works for static need help to make it dynamic (C++)
- strings in c (C++)
- Is it wrong to have a very long program if i did not find another way? (C++)
- parsing date strings mm/dd/yy?? (C++)
- Zend PHP Certification (PHP)
Other Threads in the Java Forum
- Previous Thread: Card Games Help!!!!
- Next Thread: java
| Thread Tools | Search this Thread |
Tag cloud for Java
android api applet application array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) calculator chat class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse editor error errors event eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress input integer intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia link linux list loop map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle parsing plazmic print problem program programming project recursion scanner screen server set sharepoint size smart sms smsspam sort sortedmaps sql string subclass support swing threads time tree unlimited webservices windows






