6 Questions

+4 Developer John · November 18, 2014
1. What does static mean?
2. What does null mean?
3. What does final mean?
4. Isn't a constructor basically when you want to assign a value to something right before it is used?
5. What is casting and why is it useful?
6. What is wrong with this?

Here, I'm trying to make a program that calculates the average of two variables input by a scanner with text on the screen as well.


import java.util.Scanner;

class Test{

public static void main (String [] args){

Scanner scan = new Scanner(System.in);

System.out.println("Enter two numbers so I can calculate the average.");

int Array[] = new int[2];
int average, sum = 0;

for(int counter = 0; counter < Array.length; counter++){

int Input = scan.nextInt();
Array[1] = Input;
int Input2 = scan.nextInt();
Array[2] = Input2;
sum = sum + Array[counter];
average = sum / Array.length;
System.out.println("The average of the ten numbers is " + average);


I have no errors, yet the program throws we an Exception. I would like to know why exactly I'm getting one. The Exception is the ArrayIndexOutOfBoundsException


Post a Reply


- page 3
Oldest  Newest  Rating
0 Developer John · November 22, 2014
Are you sure the ":" is only for true or false statements? I've seen it used in several different occasions before, but can't remember how exactly they were used.
0 Homer Simpson · November 22, 2014
It might be used for other things but that's the only way I know how to use it. :/ 
0 Developer John · November 23, 2014
For instance, an enhanced for loop.
+1 Developer John · November 23, 2014
Are you seriously insulting Bucky, yet on HIS website? Yes, I've tried many books in the past, and could never understand the authors. You should know that not everyone uses the same resource, because people learn in different ways. Not only insulting Bucky, but why would you even attempt to be mad at me? Am I specifically asking for code? No, I'm asking questions on things. Do you have a problem with me asking questions frequently? Yes, you do, don't lie about it. The more questions a programmer asks, the more he/she understands the concept. Have you even attempted to look at my logical definitions above? They're basically the same stated from Oracle and Bucky's videos. Oracle is my favorite resource, because I can actually understand something from them rather than books, which is why I don't read Java books anymore. Now the ":" used in code I tend to find is different for me. All I asked about it here was if I had the definition right and also what it's used in. If you're going to just stay here and keep on complaining about my questions, you might as well leave, because I'm NOT letting you make me quit learning. I've already done that two times in the past. It's not happening again. 
0 Developer John · November 24, 2014
If you're reading this comment right now, remember that the comment above this was told to someone other than Homer, or Steve. It was specifically to a person that kept on disrespecting my learning practices. Anyways, if you see any confusion in this post, those might have been replies to him/her. The post above shows a brief description of me telling this person's wrongdoings.;)

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator