wood burning stoves*
The moose likes Beginning Java and the fly likes String and String[]???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String and String[]????" Watch "String and String[]????" New topic
Author

String and String[]????

Suka Hati
Ranch Hand

Joined: Oct 28, 2004
Posts: 56
hi...
how to do if i want to copy a value of a String[] to String???

example if String[] name is x and String is y
i tried to just....x=y
but i got an error....incompatible type....

how to do this???
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
The types are incompatible because "String[]" is an array of Strings: a block of memory that holds zero, one, or more String objects. Thus, you can't set the value of one String to be the value of zero or more other Strings.

Can you explain what you're trying to do. Yes, you're trying to assign a String[] to a String, but back up. Why do you want to do that? Are you trying to get the first String from the array? If so, you wantOr, are you trying to contatenate all the Strings in the array into a single String (add them together)? If this is what you want, you can use the addition (+) operator on Strings.
[ January 27, 2005: Message edited by: David Harkness ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String and String[]????
 
Similar Threads
how to compare the values in arrays
return?
Int By Reference passing..
Please help to solve a puzzle. From whizlabs.
parsing xml string using java dom