473,396 Members | 1,827 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.

Making an int null

Hello,

I am pretty new to Java programming. I am having trouble with trying to convert an integer of value 0 to NULL. I have tried the following and it does not work:

if (a==0)
{
a=NULL;
}

Any suggestions? Is it even possible to put an integer back to NULL after it has been initialized? If asking for user input, is there a way for Java to leave the value NULL if the user simply hits "enter?"

Thank you in advance for your help.
Apr 24 '06 #1
2 58664
In java int is a primitive type so you can't set it to null.
try setting it to -1 or 0 instead.

Also using a=NULL; won't work because java is case sensitive,
(all keywords are lower case) you need to use a=null; instead.


Regards,
Alex
Mar 18 '09 #2
r035198x
13,262 8TB
If you are using 1.5 or above (you should be) then read about autoboxing.
With autoboxing you can do sill things like
Expand|Select|Wrap|Line Numbers
  1. Integer i = 20;
  2. i = null;
  3.  
Mar 18 '09 #3

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

Similar topics

3
by: Waqas | last post by:
Please see the detail of tables with fields in SQL server 2000. ·Table Student .Table Good Qualities ( It is a list of Students) (It is a list of Good Qualities)...
4
by: Next Generation Technologies Inc. | last post by:
Now what I have is a function that only works in WinIE4+ because it's uses Microsoft proprietary properties and methods: function gmshortcutkeys() { if ((parseInt(navigator.appVersion) >= 4)...
37
by: yogpjosh | last post by:
Hello All, I was asked a question in an interview.. Its related to dynamically allocated and deallocated memory. eg. //start char * p = new char; ...
3
by: sklett | last post by:
This BUG that is so ridiculous I can't believe they shipped 05 is making my life hell. I have tried the various solutions found on the web and none of them have worked thus far. What's even more...
22
by: tricard | last post by:
Good evening, I was thinking about making a very simple DOS based (console) menu for a project that i am working on, but I have no idea where to start for something like this. Does anyone have...
351
by: CBFalconer | last post by:
We often find hidden, and totally unnecessary, assumptions being made in code. The following leans heavily on one particular example, which happens to be in C. However similar things can (and...
1
by: avocado | last post by:
Hi~ I need to write a program which accept command line parameter which is the text file, load the employee file into a linked list and print it. the employee file is like: 012452 Wong...
10
by: JurgenvonOerthel | last post by:
Consider the classes Base, Derived1 and Derived2. Both Derived1 and Derived2 derive publicly from Base. Given a 'const Base &input' I want to initialize a 'const Derived1 &output'. If the...
9
by: tiwarinitin.3108 | last post by:
An interactive program that reads 3 list of numbers, which are stored in three seperate files, and creates one sorted list. Each file should contain not more than 15 numbers.
1
by: HACKhalo2 | last post by:
Hi. I'm helping a friend of mine develop an online game, which is currently outdated. The person making skins for the site came up with a cool looking NavBar (found at...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.