Before start discussion on inner class, let us discuss simple analogy. Boat and Fin(Flipper). Fin exists only for boat an to help boat to move in river. Fin would not be useful if there is no boat. But Fin is not a boat or not an part of boat. But it shares special relationship “one
Browsing category Java
Java coding practices recommended that maximum 80 characters in single line of the code. It is best for readability and understand the code. If our class require static members in more than 20 lines of our code and all lines are more than 80 characters in length, static import would help us to reduce the
Recently I had chance to meet my college junior, he said he started learning Java. I appreciated him for learning new programming skill. He is from C programming background, he said it is easy to learn java and he said java looks same like “C programming”. I was shocked. How he claims “Java programming same
Java methods accept parameters, execute business logic and return results. We can pass multiple argument to the methods and it return only one value from the methods. Some real time scenario, we may require to get more than one return values from single method. To get two return value from an method, one return value
Java encourages use of OOPS features such as inheritance and encapsulation. But in special cases, we want to restrict the change of our class or method or member variables or local variables. Here “final” keyword helps to mark the element initialized only once or design once and mark as complete. It is not allowed to
In the previous post, we discussed on creating the copy of object by clone() method. But one of main shortcome in the clone method is assigning value to final variables. Final variables can be assigned in declaration or in constructors. So your class has final members and copy of object required, it can’t be achieved
Previous post, we discussed on intention to create copy of object in java. In this post,we would discuss on different implementation of object copying. Before discuss on implementation, let us discuss on basic rule of clone copy implementation. 1) Copy of object and actual object should not refer at same object. If it is same,
Java application created by group of objects. Every time we create object to represent the real time objects. “new” operation creates and builds new object for the class. But real-time scenario, we may require to create exact copy of java object in enterprise application. Below list of use cases to create copy of objects in
The Java language supports three types of comments in code to explain the business logic in code, to explain the algorithm logic to other developers in code itself or to generate the document content in coding itself. Single line comments : //…………………. Multi line comments : /* ………………. */ Documentation comments /** Document Content */
We are writing method to accomplish business logic in application. We have to pass the argument to methods for processing. We have to understand how the arguments are passed to methods as “Pass by Value”. Understanding of this is important as we can populate and set the value of object properties in the method body