aspose file tools*
The moose likes Beginning Java and the fly likes the new math Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "the new math" Watch "the new math" New topic

the new math

James Sepello

Joined: Jul 28, 2013
Posts: 2
I am a begginer and I merged 2 training files that each worked on thier own and actually got it to run but the output is off
you put in a number from the array and get something wierd out who knows why

Enter a number to search for
49 not in the array
BUILD SUCCESSFUL (total time: 7 seconds)
sounds like a bad joke
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 39547
You're assuming that will read the entire number you typed in - it doesn't, it just reads a single character (or byte, actually, but those are identical here). "49" happens to be the numerical presentation (in the ASCII code) of the character "1".

The java.util.Scanner class (which you can wrap around allows you to read entire numbers.

Ping & DNS - updated with new look and Ping home screen widget
James Sepello

Joined: Jul 28, 2013
Posts: 2
OK thanks! i'll go back and read about the scanner again.
I agree. Here's the link:
subject: the new math
Similar Threads
Merge two arrays
Can someone please explain the following code to me...
math program help..
Merge two arrays
array read from left to right or right to left?