473,699 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to check if an object already exists

oll3i
679 Contributor
how to check if an object already exists and return reference to that object
Apr 5 '07
59 32829
oll3i
679 Contributor
please clear me that out so i learn for the future how a list can call the equals method when i defined it for a client ?
Apr 8 '07 #51
JosAH
11,448 Recognized Expert MVP
please clear me that out so i learn for the future how a list can call the equals method when i defined it for a client ?
This is what method overriding is all about. The Object class (the top of the
class hierarchy) defines an equals() method. The List calls an equals() method.
You have overridden Object's equals() method so *your* equals() method will
be called by the List because your Klient extends the Object class (implicitly)
and your class defines its own equals() method.

Your NullPointerExce ption is an entirely different problem though ...

kind regards,

Jos
Apr 8 '07 #52
oll3i
679 Contributor
so how wd that look in use?
Apr 8 '07 #53
JosAH
11,448 Recognized Expert MVP
so how wd that look in use?
Sorry, I don't understand your question.

kind regards,

Jos
Apr 8 '07 #54
oll3i
679 Contributor
cd you give me now the example how i shd use that in my case with my list and equals method
please
Apr 8 '07 #55
JosAH
11,448 Recognized Expert MVP
cd you give me now the example how i shd use that in my case with my list and equals method please
You don't have to do anything: method overriding is an intrinsic part of the Java
language. You have implemented your own equals() method and therefore
(automatically) overridden the equals() method in the Object class. You've
seen it happen yourself: the List calls your equals() method instead of the
one defined in the Object class.

kind regards,

Jos
Apr 8 '07 #56
oll3i
679 Contributor
when the list calls the equal method?
Apr 8 '07 #57
prometheuzz
197 Recognized Expert New Member
when the list calls the equal method?
Whenever you invoke the contains(...) and indexOf(...) methods from the List, for example.
Please take the time to read this tutorial:
http://java.sun.com/docs/books/tutor...jectclass.html
it explains in great detail how to override the equals(...) (and hashCode()!) method(s).
Apr 8 '07 #58
oll3i
679 Contributor
cd you look at my nullpointerexce ption post with nullpointerexce ption in the title
please
Apr 8 '07 #59
JosAH
11,448 Recognized Expert MVP
cd you look at my nullpointerexce ption post with nullpointerexce ption in the title
please
I just did; please follow up my advice I gave you in your other thread and then
come back here when your don't understand what the Exception stacktrace has
to tell you.

kind regards,

Jos
Apr 8 '07 #60

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

Similar topics

6
2460
by: lawrence | last post by:
How dangerous or stupid is it for an object to have a reference to the object which contains it? If I have a class called $controllerForAll which has an arrray of all the objects that exist, what happens if one of those objects, when it is created, takes a reference to the object that contains it? Do bad things happen? class McShow {
2
11856
by: Jonathan | last post by:
I am looking for a simple way to check if a database table exists. I keep getting advice to use "Try.. Catch" and other error handling methods, but I obviously don't want to have to display an error message and stop the process every time someone loads the script after the table is created because that would mean the page could only ever run once which of course not the solution I was looking for. I simply want to know how I can check...
2
6030
by: Mike | last post by:
I´ve got a number of SPAN elements named "mySpan1", "mySpan2", "mySpan3" etc, and want to set their "style.display" to "inline". This works (only needs to work on IE5.5+): for (var x = 1; x < 20; x++) { document.all('mySpan'+x).style.display = "inline"; } But I don´t know how many SPAN elements there are, so I need to set x to a
9
7250
by: Carl Fenley | last post by:
I am successfully adding stored procedures to an Access database. However, I need to be able to check if the stored procedure of the same name already exists. Is there a way to do this other than waiting for the OleDbException caused when adding one that already exists? Here is the code snippet: Private Sub CreateStoredProcedures()
4
3011
by: jes | last post by:
hi, i have an open & delete btn. onclick of open as visio drawing opens in visio & onclick of delete the drawing gets deleted from the filesystem. The problem is i am unable to perform these actions if the file is already opened in another instance of visio. how do i check if it's already opened and then throw an error msg? thanks
14
46240
by: John Salerno | last post by:
What is the best way to check if a file already exists in the current directory? I saw os.path.isfile(), but I'm not sure if that does more than what I need. I just want to check if a file of a certain name exists before the user creates a new file of that name. Thanks.
3
11044
by: byeung | last post by:
Hi, I am trying to check if a particular record already exists in an Access database through Excel vba code. Through code obtained at another forum, I got the following: *********************************************************************** Sub TheButton()
2
35085
by: Larry | last post by:
Thanks in advance. what is the C# equivalent of the VB.net IsNothing(object) function? just trying to check to see if an object instance already exists. does someone have an example? *** Sent via Developersdex http://www.developersdex.com ***
0
6452
by: bharathreddy | last post by:
This article will explain you how to check weather a column already exists in a table before you add the column to the table using alter command. Using the system tables you can check to see weather a column already belongs to a specific table. SYSCOLUMNS is the system table which stores all the table columns information, from this column you can check weather a specific column exists in a specific table. ...
0
8704
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9192
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9054
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8895
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7781
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3071
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.