• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do i create a new Customer object each time the user chooses 1 as an option?  RSS feed

 
Hakim Sarbogu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your code does appear to create a Customers object (BTW shouldn't the class be called Customer ie no 's'). I have no idea what the Customers class is so can't really advise further without more information. Do you get any compilation or runtime messages?
 
Hakim Sarbogu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no i mean like create a unique Customer object each time the user chooses 1..
example
if (select==1){
/*then create new customer object with a name that will be different from the next time 1 will be selected again
*/
}
 
Carey Brown
Saloon Keeper
Posts: 3323
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hakim Sarbogu wrote:no i mean like create a unique Customer object each time the user chooses 1..
example
if (select==1){
/*then create new customer object with a name that will be different from the next time 1 will be selected again
*/
}

What is the specification for 'name'? Can it be numeric? Or is it supposed to be a person's name entered via the keyboard?
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hakim Sarbogu wrote:no i mean like create a unique Customer object each time the user chooses 1..
example
if (select==1){
/*then create new customer object with a name that will be different from the next time 1 will be selected again
*/
}


Hakim ,
Just for your information ,your code definitely create new Customer object each time .If you print the object of Customer you can get different has code (if you did not override the equals and hashcode).
If you need different name each time then you need to create unique name at the time of Customer object creation .For this purpose you can use SecureRandom / StringBuilder .

Thanks ,
Satya
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!