7

The difference between the wrapper class reference and the user defines the clas...

 3 years ago
source link: https://www.codesd.com/item/the-difference-between-the-wrapper-class-reference-and-the-user-defines-the-class-reference-in-java.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

The difference between the wrapper class reference and the user defines the class reference in java

advertisements

Suppose I have a custom class, say Test.

Test test = new Test(); // test is the reference.

Now when I print the value of test, it returns the hashcode .

Now consider,

Integer i = new Integer(10);

When I print the value of i, it returns 10.

Can someone help me to understand what exactly is the difference here? I believe both are object references, but for wrapper class reference, it returns the value of the object it is pointing to.


When you create a new class, it inherits the method toString() from Object. Integer class overrides that method to return the inner value.

Related Articles

What is the difference between a Windows game library and a class library?

What's the difference between a Windows Game Library and a Class Library? Is it just that one starts off by including the XNA Framework? Also, where are the differences between the Windows / Xbox360 / Zune Game Libraries? They all seem to start off w

What is the difference between a domain class diagram and a design class diagram?

Can someone briefly explain the difference between a domain class diagram and a design class diagram? I found a explanation on Yahoo answers, but I find it quite confusing.A domain model is called conceptual model in database modeling, while a design

What is the difference between initiating a class and inheriting from a class

I have a three classes A, B, and C shown below public class A { public void add(int i, int k) { } } public class B:A { public void AddInt() { add(1, 2); } } public class C { public void AddInt() { A objA = new A(); objA.add(1, 2); } } We want access

What is the difference between an abstract class and a class with only protected constructors? (.NET)

What are all the difference between an abstract class, and a class with only protected constructor(s)? They seem to be pretty similar to me, in that you can't instantiate either one. EDIT: How would you create an instance in a derived class, with a b

What is the difference between having a class as final and having a class builder as private

What exactly is the difference between a final class and having a class constructor as private. I know both can't be subclassed(correct me if i am wrong). Is their any difference?A final class cannot be extended. It prevents this final class FinalCla

What is the difference between & ldquo; Vector :: operator = & rdquo; And & ldquo; Vector :: assign & rdquo;

What is the difference between .operator=(std::initializer_list<T>) and .assign(std::initializer_list<T>) in the std::vector class? Do they do the same? http://en.cppreference.com/w/cpp/container/vector/operator%3D http://en.cppreference.com/w

What are the differences between R.styleable, R.style and R.attr?

What are the differences between R.styleable, R.style and R.attr? I found TextAppearance in all of these three classes.R.style has all styles android provided (including all Theme android provided). E.g., Theme.Translucent, Widget.AbsListView. R.attr

What is the difference between new in a builder and new in a member statement?

What is the difference between new in a constructor and new in a member declaration? Example public class PspGame { private List<string>name = new List<string>(); private List<string>_value; public PspGame() { _value = new List<string

What is the difference between a static member variable and a namespace variable?

This question already has an answer here: Namespace + functions versus static methods on a class 7 answers Whit is the difference between 1 and 2? 1: namespace Foo { int bar; } 2: class Foo { public: static int bar; } If bar is a function, then the d

What is the difference between Dim v As String () and Dim v () As String?

This may sound trivial, but what is the difference between Dim v As String() and Dim v() As String in VB.NET?No difference. From the VB.NET Language Specification on Arrays: Array types are specified by adding a modifier to an existing type name. The

What is the difference between TPC-C, TPC-E and TPC-H benchmark?

I am getting confused with different types of TPC benchmarks. What are the major differences between TPC-C, TPC-E and TPC-H benchmark?Have you tryed: http://www.tpc.org/information/benchmarks.asp ?

What is the difference between n * fun (n-1) and fun (n-1) * n

I want to write function implement n! like this: int fun(int n) { if (n <= 1) return 1; return n * fun(n-1); } I want to know that what the difference between n * fun(n-1) and fun(n-1)*n. which one is better?One is right-recursive and one is left-rec

What is the difference between a regular Rails application and a Rails API?

In the process of learning Rails, I read about how we could combine it with some front-end MV* JavaScript frameworks - such as Backbone.js, Angular.js, or Ember.js - to improve the UX. This introduced (to me) the concept of using Rails as an API, ins

What is the difference between didMove (to display: SKView) and didMoveToView (view: SKView)?

As in the title, what is the difference between didMove(to view: SKView) and didMoveToView(view: SKView)? I understand that didMoveToView is the method and that view is of type SKView in the older(?) version. I don't understand the deal with 'to view

What is the difference between POCL (Portable Computing Language) and OpenCL?

What is the difference between POCL(Portable Computing Language) and OpenCL, and what are the advantages POCL? http://pocl.sourceforge.net/ Does POCL have a C-like language, which is different from OpenCL, a different compiler (Clang> = 3.2), differe

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK