java - Explain this code (not getting the result i need) -
package javaapplication54; public class javaapplication54 { static int monkey = 8; static int thearray[] = new int[1]; public static void main(string[] args) { // attempted 2 ways try set monkey = thearray[0]; monkey = thearray[0]; thearray[0] = monkey; //i tried result 8; system.out.println(thearray[0]); }
}
i trying result 8, printing out thearray[0] result zero.
run: 0 build successful (total time: 0 seconds)
you assigned thearray[0]
in line monkey = thearray[0]
thearray[0]
0
when first initialized thearray
@ line:
static int thearray[] = new int[1];
Comments
Post a Comment