Monday, 15 September 2014

java - how to define a global boolean array in Netbeans? What are the imports required? -



java - how to define a global boolean array in Netbeans? What are the imports required? -

i wrote code 1 of recent projects, new @ netbeans, on declaring boolean array globally, shown below, getting error.

boolean[] car1=new boolean[25]; car1[0]=true;

is showing error

create class "car1" in bundle create class "main_file" in bundle

i tried declare within events, did peace couldn't above main function.

public class blah { public static boolean[] newbooleanarray = new boolean[25]; public static void main(string[] args) { newbooleanarray[0] = true; } }

define boolean array outside of method, , give visibility modifier (public, private, protected, etc). if using in static method (like main method above), add together static modifier. above code tested , working.

java arrays boolean netbeans-8

1 comment:

  1. I found this article easy to understand and very helpful. Can’t wait to see the other posts. Thank you for sharing!


    Melbourne SEO Service

    ReplyDelete