Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

String and String[]????  RSS feed

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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???
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!