473,781 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Null vs undefined

I have a structure (which happens to be a Java DataBean that contains some
string arrays) that is giving me an error.

The error at the "for" statement is:

Object reference not set to an instance of an object.

Here is the code where chDataBean is the structure.
chDataBean.vouc herNumber is a string array of voucher numbers. But if there
are no numbers the debugger shows it as <undefined value>. But other fields
are showing as null in the debugger. What is the difference? How would I
test for each one? I assume I would have to do a test before the "for"
statement, since that is where I am getting the error.
*************** *************** *************** *************** ***
chDataBean = checkHistorySer vice.readCheckH istory(
elDataBean.empl oyeeIds[ktr],
ruDataBean.empl oyerList[1][0],
"2006",
Session.Session ID);

for(ktr1=0;ktr1 <= chDataBean.vouc herNumber.GetUp perBound(0);ktr 1++)
{
GetPayStatement Data(ref sCheckLine,objS treamWriter,
elDataBean.empl oyeeIds[ktr],chDataBean.vou cherNumber[ktr1],chDataBean.pay Date[ktr1],
ruDataBean.empl oyerList[1][0],eDataBean);
}
*************** *************** *************** *************** ************

Thanks,

Tom
Apr 18 '06 #1
6 6080
tshad <ts**********@f tsolutions.com> wrote:
I have a structure (which happens to be a Java DataBean that contains some
string arrays) that is giving me an error.

The error at the "for" statement is:

Object reference not set to an instance of an object.

Here is the code where chDataBean is the structure.
chDataBean.vouc herNumber is a string array of voucher numbers. But if there
are no numbers the debugger shows it as <undefined value>. But other fields
are showing as null in the debugger. What is the difference? How would I
test for each one? I assume I would have to do a test before the "for"
statement, since that is where I am getting the error.


They're the same thing - I don't know why the debugger shows them
differently, although it might be that it shows local variables which
have been assigned a value as null, but local variables which just
haven't been assigned yet as "undefined value".

Comparing with null would be better in either case.

By the way - if your array is a one-dimensional one, using
GetUpperBound is a bit messy compared with:

for (ktr1=0; ktr1 < chDataBean.vouc herNumber.Lengt h; ktr1++)

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 18 '06 #2
Hi,
They're the same thing - I don't know why the debugger shows them
differently, although it might be that it shows local variables which
have been assigned a value as null, but local variables which just
haven't been assigned yet as "undefined value".

I think that both the debugger and the intellisense display <undefined
value> instead of null either way
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Apr 18 '06 #3

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
tshad <ts**********@f tsolutions.com> wrote:
I have a structure (which happens to be a Java DataBean that contains
some
string arrays) that is giving me an error.

The error at the "for" statement is:

Object reference not set to an instance of an object.

Here is the code where chDataBean is the structure.
chDataBean.vouc herNumber is a string array of voucher numbers. But if
there
are no numbers the debugger shows it as <undefined value>. But other
fields
are showing as null in the debugger. What is the difference? How would
I
test for each one? I assume I would have to do a test before the "for"
statement, since that is where I am getting the error.
They're the same thing - I don't know why the debugger shows them
differently, although it might be that it shows local variables which
have been assigned a value as null, but local variables which just
haven't been assigned yet as "undefined value".

Comparing with null would be better in either case.


Great.
By the way - if your array is a one-dimensional one, using
GetUpperBound is a bit messy compared with:

for (ktr1=0; ktr1 < chDataBean.vouc herNumber.Lengt h; ktr1++)
Why?

Tom
--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Apr 18 '06 #4

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
Hi,
They're the same thing - I don't know why the debugger shows them
differently, although it might be that it shows local variables which
have been assigned a value as null, but local variables which just
haven't been assigned yet as "undefined value".

I think that both the debugger and the intellisense display <undefined
value> instead of null either way


Actually, I am looking at a structure and am getting something like:
field1 null
field2 null
field3 null
field4 <undefined value>
field4 <undefined value>
field3 null
field4 <undefined value>
field3 null
field4 <undefined value>
....

Tom
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Apr 18 '06 #5
tshad <ts**********@f tsolutions.com> wrote:
By the way - if your array is a one-dimensional one, using
GetUpperBound is a bit messy compared with:

for (ktr1=0; ktr1 < chDataBean.vouc herNumber.Lengt h; ktr1++)


Why?


Because it's easier to read (and write) .Length than .GetUpperBound( 0).

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 18 '06 #6
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
tshad <ts**********@f tsolutions.com> wrote:
> By the way - if your array is a one-dimensional one, using
> GetUpperBound is a bit messy compared with:
>
> for (ktr1=0; ktr1 < chDataBean.vouc herNumber.Lengt h; ktr1++)
Why?


Because it's easier to read (and write) .Length than .GetUpperBound( 0).


Reasonable.

Thanks,

Tom
--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Apr 18 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
3088
by: Don Vaillancourt | last post by:
What's going on with Javascript. At the beginning there was the "undefined" value which represented an object which really didn't exist then came the null keyword. But yesterday I stumbled across "null" string. I know that I will get an "undefined" when I try to retrieve something from the DOM which doesn't exist. I have used null myself to initialize or reset variables. But in which
3
2373
by: k0t1k | last post by:
Sorry if I am kicking the dead horse, but why null == undefined in Rhino? This is what I got running Rhino shell. $ java -jar js.jar Rhino 1.6 release 1 2004 11 30 js> null == undefined true js> var a; js> var b = null; js> a == b
2
2243
by: Thomas G. Marshall | last post by:
Arthur J. O'Dwyer <ajo@nospam.andrew.cmu.edu> coughed up the following: > On Thu, 1 Jul 2004, Thomas G. Marshall wrote: >> >> Aside: I've looked repeatedly in google and for some reason cannot >> find what is considered to be the latest ansi/iso C spec. I cannot >> even find C99 in its final draft. Where in ansi.org or the like do >> I find it? > > The official C99 specification is copyright ISO and distributed by > various national...
99
5194
by: Mikhail Teterin | last post by:
Hello! Consider the following simple accessor function: typedef struct { int i; char name; } MY_TYPE; const char *
27
4234
by: David W | last post by:
I'm almost tearing my hair out. A colleague claimed that a null reference can exist, like this: void f( int& p ) { printf( "%d\n", p ); } int main (int argc, char *argv) {
76
4719
by: valentin tihomirov | last post by:
As explained in "Using pointers vs. references" http://groups.google.ee/group/borland.public.delphi.objectpascal/browse_thread/thread/683c30f161fc1e9c/ab294c7b02e8faca#ab294c7b02e8faca , the pointers are allowed to be null, while references must refer an existing variable of required type. The null is normally used for making optional parameters. But there is no way to pass null reference in C#. Something is missing.
6
5586
by: Java script Dude | last post by:
Small glitch (IMHO) in JavaScript is related to isNaN() boolean function. If passed a null, it returns true which is incorrect. This one cause me quite a bit of grief until I detected it and was able to code around it. Anybody know the reasoning for the result being false and not true for isNaN(null). - JsD
6
1467
by: jason.cipriani | last post by:
Is it OK to dereference NULL pointers if the only thing you are doing is storing them in a reference then comparing addresses to NULL again later, as in: === BEGIN EXAMPLE === Something g_something; const Something & getSomething () { if (condition)
2
5522
by: Doogie | last post by:
Hi, I'm writing Javascript code to parse out a query string. I want to handle the case where a parameter value may not be sent. So consider a parameter called "State". If the user doesn't pass that in if I do this: var state = <%=Request.QueryString%> This returns an undefined object that I can't seem to do any checks
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
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
9939
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
8964
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...
1
7486
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6729
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
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5507
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2870
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.