472,988 Members | 2,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

incomparable types: int and <nulltype>

1
Expand|Select|Wrap|Line Numbers
  1. class Search
  2. {
  3.     public static void main (String[] args)
  4.     {
  5.         int position;
  6.         int counter = 0;    
  7.         String para;    
  8.  
  9.         para = Keyin.inString("insert a paragraph");    
  10.  
  11.         do {    
  12.         position = para.indexOf(' ');
  13.         para = para.substring ( position + 1, para.length () -1); 
  14.         counter = counter + 1;
  15.         } while ( position != null ) ;
  16.  
  17.         counter = counter + 1 ;
  18.         System.out.println(counter);
  19.             }
  20.         }
  21.  
aw well the debug says :

incomparable types: int and <nulltype>
} while ( position != null ) ;
^

HEHE any suggestions :P
Oct 15 '07 #1
3 20981
pbmods
5,821 Expert 4TB
Heya, vakon. Welcome to TSDN!

Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

Please use CODE tags when posting source code:

[CODE=java]
Java code goes here.
[/CODE]
Oct 15 '07 #2
r035198x
13,262 8TB
Expand|Select|Wrap|Line Numbers
  1. class Search
  2. {
  3.     public static void main (String[] args)
  4.     {
  5.         int position;
  6.         int counter = 0;    
  7.         String para;    
  8.  
  9.         para = Keyin.inString("insert a paragraph");    
  10.  
  11.         do {    
  12.         position = para.indexOf(' ');
  13.         para = para.substring ( position + 1, para.length () -1); 
  14.         counter = counter + 1;
  15.         } while ( position != null ) ;
  16.  
  17.         counter = counter + 1 ;
  18.         System.out.println(counter);
  19.             }
  20.         }
  21.  
aw well the debug says :

incomparable types: int and <nulltype>
} while ( position != null ) ;
^

HEHE any suggestions :P
As the error message says, you cannot compare an int (primitive) with null (reference type).
Perhaps you want to compare position with zero?
Oct 15 '07 #3
Hi,
Change primitive type "int" to reference type "Integer".
Aug 28 '11 #4

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

Similar topics

3
by: John Dibling | last post by:
Could somebody please direct me to a location in the standard where POD types are defined? That is, where in the standard is it defined what attributes a POD type has that a non-POD hasn't? Also,...
5
by: Andy Skypeck | last post by:
I am looking for some validation against a dubious coding practice that prevails where I work. C types defined in types.h (Linux) or stdint.h (Windows, C99?) are used as if they belong to the C++...
8
by: Shailesh | last post by:
One problem I've been wrestling with for a long time is how to use the C++ integral data types, vis-a-vis their size. The C++ rules guarantee that a char is at least 1 bytes, a short and int at...
188
by: infobahn | last post by:
printf("%p\n", (void *)0); /* UB, or not? Please explain your answer. */
5
by: Zach | last post by:
When it is being said that, "value types are created on the stack or inline as part of an object". If a value type is created in an object, and that object is being called, the value type in that...
5
by: max | last post by:
Dear all, I did the following analysis to conclude that the following pointer types are not compatible. Please let me know If my analysis and interpretation of the C standard are correct: ...
58
by: jacob navia | last post by:
Hi people I have been working again in my tutorial, and I have finished the "types" chapter. If you feel like "jacob bashing" this is the occasion! I am asking for criticisms, or for things I may...
55
by: tonytech08 | last post by:
How valuable is it that class objects behave like built-in types? I appears that the whole "constructor doesn't return a value because they are called by the compiler" thing is to enable...
4
by: BurnTard | last post by:
Okay, new programming language for Burnie. Can anyone tell me how to write a try catch statement for incomparable types? I can't figure out how to get emacs to give me the actual error, and not the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.