473,396 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Difference

What is the difference between object and object reference?And what do the the following two statements signify?
Statement1::

String s="Bagmita";

Statement2::

String s=new String("Bagmita");
Jan 10 '07 #1
7 1388
r035198x
13,262 8TB
What is the difference between object and object reference?And what do the the following two statements signify?
Statement1::

String s="Bagmita";

Statement2::

String s=new String("Bagmita");
The difference between these two statements can be infered from this thread.
In the first statement s holds a string literal value. s refers to literal "Bagmita".

In the second statement, s holds a reference to an object that has just been created in memory.

String s1="Bagmita";
String s2=new String("Bagmita");

s1 == s2 compares the memory addresses (object references) and so returns false. But s1.equals(s2) compares what these 2 are refering to (references) and so returns true.
Jan 10 '07 #2
The difference between these two statements can be infered from this thread.
In the first statement s holds a string literal value. s refers to literal "Bagmita".

In the second statement, s holds a reference to an object that has just been created in memory.

String s1="Bagmita";
String s2=new String("Bagmita");

s1 == s2 compares the memory addresses (object references) and so returns false. But s1.equals(s2) compares what these 2 are refering to (references) and so returns true.
thank you.i am preparing for java certification,can you please suggest me certain good websites for mock tests?
Jan 11 '07 #3
r035198x
13,262 8TB
thank you.i am preparing for java certification,can you please suggest me certain good websites for mock tests?
I suggest you try mock tests after you've had a thorough revision of the main concepts of Java. The Java classes on this site specify some of the things you'll need to know to pass that test. When are you planning on taking the test?
Jan 11 '07 #4
I am going to take the test by the end of this month..I have tried out many mock tests from various sites but my score is not so satisfactory especially in collections and garbage collection ..also threads
Jan 11 '07 #5
r035198x
13,262 8TB
I am going to take the test by the end of this month..I have tried out many mock tests from various sites but my score is not so satisfactory especially in collections and garbage collection ..also threads
Feel free to post any questions you are not comfortable with including your suggested solutions.
Jan 11 '07 #6
int[][] makeArray( int size)
{ int[][] triArray = new int[size] [];
int val=1;
for( int i = 0; i < triArray.length; i++ )
{ triArray[i] = new int[i+1];
for( int j=0; j < triArray[i].length; j++ )
{ triArray[i][j] = val++;
}
}
return triArray;
}

Can you please explain the flow transfer of this program and what its output will be?
Jan 11 '07 #7
r035198x
13,262 8TB
int[][] makeArray( int size)
{ int[][] triArray = new int[size] [];
int val=1;
for( int i = 0; i < triArray.length; i++ )
{ triArray[i] = new int[i+1];
for( int j=0; j < triArray[i].length; j++ )
{ triArray[i][j] = val++;
}
}
return triArray;
}

Can you please explain the flow transfer of this program and what its output will be?
Like I said post your suggested solution first.
Jan 11 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
3
by: bbawa1 | last post by:
Hi, I have a table which has a field ItemsReceived of type datetime. I have a grid view which has two columns. In first column i have to show the data from field ItemsReceived and in second...
12
by: Petronius | last post by:
Hallo, does anyone have an idea how to implement difference lists in Javascript? Thanks allot in advance
5
by: Julius | last post by:
Hej dudes, I need to calc the difference between two timestamps / dates ... For example what i need to calculate: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.07 - 21:13:04 Difference:...
9
by: viki1967 | last post by:
Hi all! This new forum its great! :) Congratulations !!! My answer: why this my code not working? Nothing error but not work the difference.... : <html>
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.