Hi all,
I am new to
Java and I have written two java classes. The first class will accept an unconstrained array and then output the even numbers in the array. the first class compiled without error while the application class show the following error message which I cannot resolve:
DriverUnArray.java:19:cannot find symbol
symbol: method readline()
location: class java.io.BufferedReader
EvenNumbers = new Interger(KeyboardInput.readline()).intValue();
See the codes below:
UnArrays Class:
//
//
//
//
import java.io.*;
import java.awt.* ;
import java.lang.*;
import java.util.Formatter;
public class UnArrays{
int length;
final int lowerBound=0;
int commaFlag;
int[] ranNumbers;
public static BufferedReader KeyboardInput = new BufferedReader(new InputStreamReader(System.in));
public UnArrays(int size){
length = size;
ranNumbers = new int[length];
}
public void InputRanNumbers() throws IOException {
int index = lowerBound;
System.out.print("Random Numbers {" +ranNumbers[0]);
while (index == ranNumbers.length){
System.out.print("," + ranNumbers[index]);
index++;
}
System.out.print("}\n");
}
public void EvenNumbers(){
int index; commaFlag = 1;
System.out.print("Even Numbers{");
for(index = lowerBound; index < ranNumbers.length; index++){
if(ranNumbers[index]%2==0){
if (commaFlag==0){
System.out.print("," + ranNumbers[index]);
}
else {
System.out.print(ranNumbers[index]);
}
}
}
}
}
DriverUnArray:
import java.io.*;
import java.awt.* ;
import java.lang.*;
import java.util.Formatter;
public class DriverUnArray{
public static BufferedReader KeyboardInput= new BufferedReader(new InputStreamReader(System.in));
public static void main(
String[] args)
{
int EvenNumbers;
System.out.println("Input Random Numbers");
EvenNumbers = new Integer(KeyboardInput.readline()).intValue();
UnArrays newUnArray = new UnArrays(EvenNumbers);
newUnArray.InputRanNumbers();
newUnArray.EvenNumbers();
}
}
Thanks.
Oochi