Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about first class object

 
deepak mehta
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello sir
sir what is first class objects in java programming is it similar declared object or other
please reply me soon it is urgent.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"First class object" is not a Java language concept; it's a computer science concept, usually only used when you're talking about something that isn't an object, or isn't usually an object. For example, in Java, a method isn't an object; but in some langauges, a method is, indeed, a "first class object."
 
Svend Rost
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In connection with EFH's reply: aka. "first class citizens"
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been confused by this phrase as well. Is it simply a way of saying that something is "indeed" an object?

For example, if I said, "In Java, an array is a first class object," this would simply mean that Java arrays are, in fact, objects (whereas in other languages they might not be). Is that correct?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pretty much, yeah. You can imagine a language which offered "degrees of objecthood", so that something-or-other could be a first-class object, or only have some object-like properties.
 
M Beck
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
usually a "first-class" thing in a language is a thing you can use the language's own syntactic and semantic structures to manipulate, without having to invoke library code. so Objects are first-class in Java, and so are ints, booleans, doubles, and so forth. but List's, Map's, and Swing Container's are not first-class; they're higher-level constructs built on top of first-class objects.

i suppose one could argue that a thing isn't first-class unless it's possible to create new instances of it at run-time, store them in variables, pass them around, and so on; i'm unsure if there's any widespread agreement on whether or not that's considered a requirement for "first-class" status. if it is required, then methods (functions) could not be considered first-class things in Java. (personally, i would agree with this notion.)
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting. Thanks for the responses!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic