473,666 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simple java compiler error

JavaStudent07
64 New Member
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 IndexOutOfBound sException 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 1533
horace1
1,510 Recognized Expert Top Contributor
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 Recognized Expert Specialist
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
7993
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 as a standard portable part of the core language, the LISP package, and the java.lang package, respectively. Both have big integers, although only LISP has rationals as far as I can tell. Because CL supports keyword arguments, it has a wider range...
1
6912
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
8532
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
4
11936
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 underlined in red. It is saying it is a syntax error and to delete the tokens. I'd like to use the code below in my program i am working on for my hobby. It will make life so much easier when i get past the compiler error.
4
5810
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 jdk11_path to: Java Development Kit 1.1 installation path (JDK11_PATH) =
1
3305
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 # ant -version Apache Ant version 1.5 compiled on October 15 2002
4
4381
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 machines in C# where the machine can use the enumerated 'state' to execute (thus the term 'machine' as in 'state machine') the machine operations as this requires boolean operations to be performed on the state. .....
0
3891
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 programming but on Java programming but I will cover all the important aspects of object oriented programming as Java has full support for object-oriented programming even though it is not a fully object-oriented language (in the sense that you can write...
1
2666
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
8440
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8352
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
8780
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7378
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
6189
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
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
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.