• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

could we say 'out' is inner class of 'System' class ?

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this Friday i have been studying inner classes, after studying i think that i got something to apply, and that is:
suppose could i say that is inner class of and is static method of inner class .

 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Saed Hussein wrote:this Friday i have been studying inner classes, after studying i think that i got something to apply, and that is:


First of all, why are you studying inner classes That's not on the OCA exam at all. It's one of the famous topics on the OCP exam.

But out is definitely not an inner class of the System class! out is nothing more but a public final class (static) variable of the System class and the println (and print) method is simply an instance method of the type of class variable out. So the System class looks similar toAnd you can use this custom System class as well

Hope it helps!
Kind regards,
Roel
 
Saed Hussein
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why i'm studying inner classes is, Inner classes has subtopic of anonymous classes which are prerequisite to understand lambda expression as I think.
any how thank you for your reply; also your reply will help me letter and also other newbies.
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the Java API docs, you'll see that out is a public staic final field of type PrintStream. The print & println methods all reside in the java.io.PrintStream class and not in the System class
 
Bartender
Posts: 2230
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if System.out was a static nested class it would probably be called System.Out because of the naming convention.
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Saed Hussein wrote:Why i'm studying inner classes is, Inner classes has subtopic of anonymous classes which are prerequisite to understand lambda expression as I think.


Anonymous inner classes are indeed a kind of inner classes. But are not required to understand lambda expressions. And although lambda expressions can (and will) definitely be used to replace anonymous inner class, you don't need to know about anonymous inner classes to understand (and create) simple lambda expressions (which is one of the OCA exam objectives).

Assume this (functional) interfaceYou could create a class which implements this interfaceOr you could create an instance of an anonymous inner class implementing this interfacePrior to Java 8, you had to create either a class (implementing this interface) or creating an instance of an anonymous inner class implementing this interface. And as you can see from the above code snippets, you have 5 lines of code, but only two lines are really important, 3 are utterly boring. Since Java 8 you could create a lambda expression and reduce it to one single, easy to read lineAnd as you can see from this code snippet, all 3 alternatives are equivalent and produce the same outputFrom the above code snippets, you could see the lambda expression (on line1) as a more concise way of class Concat. And class Concat is nothing more but a very simple class which implements an interface with just one method (which are all OCA exam objectives). So in my opinion there is no need to learn the tricky syntax of anonymous inner class (an OCP exam objective) to understand lambda expressions.

Hope it helps!
Kind regards,
Roel

Disclaimer: anonymous inner classes is not a topic of the OCA certification exam. I used them for demonstration purposes only. So if you don't understand what's happening, don't worry and just move on! Inner (or nested) classes (including anonymous inner classes) is an OCP exam objective.
 
Saloon Keeper
Posts: 22267
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everything else aside, the clue is the name: "out". If it was a class (and named according to standards), it would have been named "Out" instead, because the convention is that class names start with a capital letter.
 
Everybody's invited. Even this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic