5
answers
0
watching
221
views
23 Aug 2018
2)What code would you add if you wanted to change it so that the user was able to continue entering a filename until the method initialize InventoryFromFile could successfully be exceuted? (e) Suppose I have the following class definition: 1 1/A TelevisionShow is a new type that consists of a String) for the actors |/ /a String for the name, and a string for the network public class Television Show private String[] actors; private String name; private String network; //this method will return whether or not the property //actors contains actor Name or not public static boolean hasActor (String actor Name) for (int i-0; i < actors.length; i++) { if (actors[i].equals (actorName)) { return true; return false; Unfortunately, when I try to compile this code, I get the following error: Television Show.java:11: non-static variable actors cannot be referenced from a static context for (int i=0; i < actors.length; i++) { Television Show.java:12: non-static variable actors cannot be referenced from a static context if (actors[i].equals(actorName)) { 2 errors What does this error mean and how can I fix it?
2)What code would you add if you wanted to change it so that the user was able to continue entering a filename until the method initialize InventoryFromFile could successfully be exceuted? (e) Suppose I have the following class definition: 1 1/A TelevisionShow is a new type that consists of a String) for the actors |/ /a String for the name, and a string for the network public class Television Show private String[] actors; private String name; private String network; //this method will return whether or not the property //actors contains actor Name or not public static boolean hasActor (String actor Name) for (int i-0; i < actors.length; i++) { if (actors[i].equals (actorName)) { return true; return false; Unfortunately, when I try to compile this code, I get the following error: Television Show.java:11: non-static variable actors cannot be referenced from a static context for (int i=0; i < actors.length; i++) { Television Show.java:12: non-static variable actors cannot be referenced from a static context if (actors[i].equals(actorName)) { 2 errors What does this error mean and how can I fix it?
29 Jun 2023
neonguts087Lv2
21 Feb 2022
Already have an account? Log in
Casey DurganLv2
25 Aug 2018
Already have an account? Log in