Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

program on simple string array  RSS feed

 
gayathriy Nandakumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi...i am new to java programming..using string array how do i create a unique number for each string entered so that i produce that unique number for the infinite number of times when the same string is entered
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each String object has a hashCode method that will produce the same value for the String object each time it is invoked.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Lynn:
Each String object has a hashCode method that will produce the same value for the String object each time it is invoked.


But it will not (and cannot) be unique among all the different possible (finite) String values.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!