• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

question about first class object

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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."
 
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In connection with EFH's reply: aka. "first class citizens"
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting. Thanks for the responses!
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic