473,320 Members | 2,035 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,320 software developers and data experts.

simple java compiler error

JavaStudent07
Expand|Select|Wrap|Line Numbers
  1. H:\>c:\j2sdk1.4.1\bin\javac.exe BubbleSort.java
  2.  
  3. H:\>c:\j2sdk1.4.1\bin\java.exe BubbleSort
  4. Please input the name of the file from which the data will be acquired.  Be sure to use the entire path.
  5. h:\Numbers.txt
  6. 67 34 5 6 23 12
  7. 16
  8. First Character: 6
  9. PlaceHolder: 1
  10. Character:7
  11. PlaceHolder: 2
  12. Character:
  13. Final Concatenated Result of While: 67
  14. PlaceHolder: 4
  15. Character:4
  16. PlaceHolder: 5
  17. Character:
  18. Final Concatenated Result of While: 34
  19. PlaceHolder: 7
  20. Character:
  21. Final Concatenated Result of While: 5
  22. PlaceHolder: 9
  23. Character:
  24. Final Concatenated Result of While: 6
  25. PlaceHolder: 11
  26. Character:3
  27. PlaceHolder: 12
  28. Character:
  29. Final Concatenated Result of While: 23
  30. PlaceHolder: 14
  31. Character:2
  32. PlaceHolder: 15
  33. Character:
  34. Final Concatenated Result of While: 12
  35. Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 16
  36.         at java.lang.String.charAt(String.java:460)
  37.         at BubbleSort.Sort(BubbleSort.java:70)
  38.         at BubbleSort.main(BubbleSort.java:14)
  39.  
  40. H:\>
I dont know why the IndexOutOfBoundsException occurred, anybody know a simple solution?(the program is in the works so its a little confusing but post if you need to see it.)
Thanks in advance,
Steve
Mar 5 '07 #1
2 1518
horace1
1,510 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. H:\>c:\j2sdk1.4.1\bin\javac.exe BubbleSort.java
  2.  
  3. H:\>c:\j2sdk1.4.1\bin\java.exe BubbleSort
  4.  
  5. Final Concatenated Result of While: 12
  6. Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 16
  7.         at java.lang.String.charAt(String.java:460)
  8.         at BubbleSort.Sort(BubbleSort.java:70)
  9.         at BubbleSort.main(BubbleSort.java:14)
  10.  
  11. H:\>
Steve
It means you have tried to access a character in a string where the index given is outside the string, e.g. you have a string "hello" and try to index charAt(10).
http://java.sun.com/j2se/1.4.2/docs/...Exception.html

The error is in line 70 of your code !
Mar 5 '07 #2
Ganon11
3,652 Expert 2GB
If you can't fix the problem from horace's help, you should probably provide the context in which you are calling the Sort function (i.e. the lines where you actually call it) and the relevant section in Sort.
Mar 5 '07 #3

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

Similar topics

73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
1
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
4
by: 3rdshiftcoder | last post by:
Hi- I'd like to use this class from a book but am getting a compiler error. On the line private List < String > list; p.932 Chapter 19 found in the code below in the eclipse editor it is...
4
by: acemann7 | last post by:
Windows 2000 udb v 7.2 Got the latest fixpak 13 Applied it. Still can't get a single java sp to run. I used to get reason "2"... now reason "0" - reason 0 is not even documented. I point...
1
by: Markus Wollny | last post by:
Hi! I am trying to build PostgreSQL 7.4.3 with Java enabled; I've got Apache Ant version 1.5 and j2sdk1.4.1_05 installed: Verifiying ant: # which javac /usr/java/j2sdk1.4.1_05/bin/javac #...
4
by: Shawnk | last post by:
This post is intended to verify that true value semantics DO NOT EXIST for the Enum class (relative to boolean operations). If this is true then (thus and therefore) you can not design state...
0
by: r035198x | last post by:
Inheritance We have already covered one important concept of object-oriented programming, namely encapsulation, in the previous article. These articles are not articles on object oriented...
1
by: hostel | last post by:
HTML PAGE <html> <body> <form action="second.jsp" method="get"> YOur name <input type=text name="name"> <input type=submit > </form> </body> </html>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.