aspose file tools*
The moose likes Beginning Java and the fly likes question about first class object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "question about first class object" Watch "question about first class object" New topic
Author

question about first class object

deepak mehta
Greenhorn

Joined: Jan 25, 2005
Posts: 15
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.


deepak kr.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

"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."


[Jess in Action][AskingGoodQuestions]
Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904
In connection with EFH's reply: aka. "first class citizens"
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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

Joined: Jan 14, 2005
Posts: 323
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

Joined: Aug 31, 2004
Posts: 11343

Interesting. Thanks for the responses!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: question about first class object