The following code compiles just fine, I just wanted to know if I could do everything in a much shorter form. Pardon me if i'm overlooking something really simple. Also I used a.length-a.length instead of 0 because I'm doing this to show that I know WHY this or that for APCSA.
public class main
{
public static void main(String[] args) //Goal is to make a quick program that finds the largest value in an array.
{
int a[] = new int[]{2,2,3,4,5,6,6,2,8}; //Arbitrary Values
int lnum = 0;
for(int i = a.length-a.length; i < a.length; i++){ // Used a.length-a.length instead of 0
if (i==a.length-a.length){ // Used a.length-a.length instead of 0
lnum = a[i];
}
else if(a[i]>lnum && a[i]>a[i-1]){
lnum = a[i];
}
}
System.out.println(lnum);
}
}