Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

object issue

 
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How can we write a program using employee object as map key where employee having 3 property ( to check knowledge of immutability) a. Name : String b. DOB : Date c. Age : Int


Thanks
 
Saloon Keeper
Posts: 6448
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You posted this in the PHP forum; is the question about PHP or Java?
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's specific to java 8  but not sure how could we put it there.
 
Tim Moores
Saloon Keeper
Posts: 6448
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will move it there for you, but that is the last time I will move a topic to the appropriate forum for you. You have been around the Ranch long enough to understand about the various forums, and post to the appropriate one. Any other Java topics in the PHP forum will be just locked.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any updates by experts please?

Thanks
 
Marshal
Posts: 69472
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

John Ken wrote:. . . a. Name : String b. DOB : Date c. Age : Int . . .

I suggest you start by telling us why, I think, that is incorrect design.
 
John Ken
Ranch Hand
Posts: 388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why do you think that it is incorrect design we have to show that we know what a  immutability is with this example if someone could write appropriate code so that we could prove it?


Thanks
 
Tim Moores
Saloon Keeper
Posts: 6448
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, we can, but we won't.

John, we've been over this many times - this site is not for handing you answers, it is about you learning to do stuff yourself. Please finally stop asking for answers, and take seriously what people are telling you.
 
Rancher
Posts: 4588
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's purely for showing immutability, and presumably what is required for a Map key, then write the Employee class and show us where you get.
 
Campbell Ritchie
Marshal
Posts: 69472
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Moores wrote:. . . learning to do stuff yourself. . . .

Agree. The problem I can see is much more fundamental than anything about immutability. Were you told to use that design? If so, please discuss the problem with your teacher. I have already pointed out the part I am worried about.
 
Sheriff
Posts: 7619
522
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

John Ken wrote:How can we write a program using employee object as map key where employee having 3 property ( to check knowledge of immutability)


Along the way of this task also research, why having Map keys which can be mutated is a bad idea. You could easily get some sort of questions in programming job interviews.
 
Campbell Ritchie
Marshal
Posts: 69472
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Were you really told to use that dreadful design? That object can either be in a consistent state or it can be immutable, in which case it can no longer be relied on to be in a consistent state.
Work out what will happen to an object in a consistent state it you wait long enough. Please work it out; finding the problem isn't rocket science, but it does entail a bit of effort.

By the way: when you said Date did you mean this Date Class? A badly designed class, which nobody should use any more. There is more about immutability in the Java™ Tutorials, and something about dates, too.
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic