bro, try ni. kaw nalang limpyo. ako jud ni code para nmo 
Code:
import java.util.Scanner;
class ArrayNumbers{
public static void main(String[] args){
try{
Scanner in = new Scanner(System.in);
System.out.print("String input: ");
String str = in.nextLine();
new ArrayNumbers().process(str);
}catch(Exception e){
System.err.println("Error running program.");
}
}
private void process(String str){
String digits = removeTrailing(",", extractString(str));
int[] arrayInt = convertToIntArray(digits);
int highestInt = getHighestInt(arrayInt);
int lowestInt = getLowestInt(arrayInt);
int closestToZero = getClosetToZero(arrayInt);
display(str, digits, arrayInt, highestInt, lowestInt, closestToZero);
}
private void display(String inputString, String digitsArray, int[] intArray, int highestInt, int lowestInt, int closestToZero){
System.out.println("Array: [" + digitsArray + "]");
System.out.println("Length of String: " + inputString.length());
System.out.println("Length of Array: " + intArray.length);
System.out.println("Highest int: " + highestInt);
System.out.println("Lowest int: " + lowestInt);
System.out.println("Closest to zero: " + closestToZero);
}
private String extractString(String str){
char[] ch = str.toCharArray();
String digits = "";
for(char c : ch){
if(c == '-'){
digits += Character.toString(c);
}else if(Character.isDigit(c)){
if(c == '0')
digits = removeTrailing("-", digits);
digits += Character.toString(c) + ",";
}
}
return digits;
}
private String removeTrailing(String pattern, String digitStr){
if(digitStr.lastIndexOf(pattern) > -1){
digitStr = digitStr.substring(0, digitStr.length()-1);
}
return digitStr;
}
private int[] convertToIntArray(String digits){
String[] arrayStr = digits.split(",");
int[] arrayInt = new int[arrayStr.length];
for(int i=0;i<arrayStr.length;i++){
arrayInt[i] = Integer.parseInt(arrayStr[i]);
}
return arrayInt;
}
private int getHighestInt(int[] ar){
int temp = 0;
for(int a : ar){
if(a > temp)
temp = a;
}
return temp;
}
private int getLowestInt(int[] ar){
int temp = ar[0];
for(int a : ar){
if(a < temp)
temp = a;
}
return temp;
}
private int getClosetToZero(int[] ar){
int[] posArray = {1,2,3,4,5,6,7,8,9};
int[] negArray = {-1,-2,-3,-4,-5,-6,-7,-8,-9};
int posIndex = getIntIndex(getLowestPositiveInt(ar), posArray);
int negIndex = getIntIndex(getHighestNegativeInt(ar), negArray);
int closest = 0;
if(posIndex < negIndex)
closest = posArray[posIndex];
else if(posIndex > negIndex || posIndex == negIndex)
closest = negArray[negIndex];
return closest;
}
private int getIntIndex(int idx, int[] array){
for(int i=0;i<array.length;i++){
if(array[i] == idx)
return i;
}
return 0;
}
private int getLowestPositiveInt(int[] ar){
int temp = 9;
for(int a : ar){
if(a > 0){
if(a < temp)
temp = a;
}
}
return temp;
}
private int getHighestNegativeInt(int[] ar){
int temp = -9;
for(int a : ar){
if(a < 0){
if(a > temp)
temp = a;
}
}
return temp;
}
}