The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Program doesn't work!

I hope that I translate task well :
A bread is being sold at the bakery. At the start of the day n bread are baked each of them with quality x. As time passes new bread are baked with various qualities, customers come in and buy the bread. When a customer comes to the salesperson: "Give me the best bread you've got!" The salesperson takes the best bread and sells it to the customer. Help the bakery to have better bussines by always selling their customers the best bread. n(1<=n<=100000) is given and after that n numbers x. The number x describes the quality of the bread. The number m follows after that, then m(1<=m<=100000) numbers y. y describes the events during the day. If y is zero. it means that a customer came and bought the best bread , so it has to write out the quality of the sold bread or "No" if there is no bread. If y isn't zero, it means that a new bread has been baked of the quality y which can be bought from that moment on.

Re: Program doesn't work!

Please post the full text of the compiler's error message that includes the source statement with the error.
The message should show the source with a ^ under the location of the error.
Here is a sample from the javac compiler:

Now, when I compile program, nothing happened (I think program work now), but I can't insert input number to check exactness.
In Eclipse,compile working, but when I run the program,got unknown problem.I can post all code if you need to see the problem.

Re: Program doesn't work!

That's good. It means there were no compiler errors.
Or are you talking about when the code is executed?
What does the program not do that makes you say "nothing happened"?

What statements did not execute that you think should be executed? Are the statements inside a loop? What was the value of the boolean expression that controls the loop?
Add a println() statement to print out the values of the variables used in the boolean expression so you can see what the computer sees when it executes the code.

Re: Program doesn't work!

I tried to run program, after first correct output , I get this:
Exception in thread "main" 32
java.lang.IndexOutOfBoundsException: Index: 6, Size: 6
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at Rad.out(Rad.java:44)
at Rad.main(Rad.java:25)

The arg to the get() method on line 44 is past the end of the arraylist. Remember indexes range in value from 0 to the size-1. If the arraylist has 6 items, the max index is 5.
Check that the code does not use an index past the arraylist size-1