in Education by
I would really appreciate some help on what seems to be an easy error to fix, I'm a beginner and have been stuck on this for 2 hours. Eclipse gives me two errors that expect me to start and end a random block. In the code I give, I comment on the two lines where there are errors. This is what those errors say: 1.Syntax error on token ";", { expected after this token 2.Syntax error, insert "}" to complete Block This is the code from my unfinished class (I comment where the two errors are): //import java.awt.*; import java.awt.event.*; //import java.util.Collection; //import java.util.LinkedList; import java.util.*; import javax.swing.*; public class Controller implements ActionListener { //private Model model; private View view; //create linked list to hold employees Collection c; //ERROR ON THIS LINE c = new LinkedList (); //create a few employees to use Employee emp; emp = new Employee("Hugh Jackman", "609-66-9598", 90000.00, Employee.maritalStatus.single); Manager man; man = new Manager("Software Manager", 100.00, "John Smith", "678-57-1295", 120000.00, Employee.maritalStatus.married); Worker wor; wor = new Worker("Hugo Boss", "Clothing", "Andrew Park", "534-47-9876", 15000, Employee.maritalStatus.partner); //ERROR ON THIS LINE public Controller() { view = new View(this); //model = new Model(); } public static void main(String args[]) { // instantiates itself to get its own constructor going Controller ctr = new Controller(); } public void actionPerformed (ActionEvent evt) { //System.out.println((JMenuItem)evt.getSource()); if (((AbstractButton) evt.getSource()).getText() == "Employee") { c.add(emp); view.show("Employee added!"); } } } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
write this statements in one line Collection c = new LinkedList (); Employee emp = new Employee("Hugh Jackman", "609-66-9598", 90000.00, Employee.maritalStatus.single); Manager man = new Manager("Software Manager", 100.00, "John Smith", "678-57-1295",120000.00, Employee.maritalStatus.married); Worker wor = new Worker("Hugo Boss", "Clothing", "Andrew Park", "534-47-9876",15000, Employee.maritalStatus.partner); as you initializing the object after declare the object. This are the executable statement which only allow within method only while the above is the different thing it will declare the object with the initialization so the compiler consider as one statement not 2 statement Collection c; c = new LinkedList (); this are the two statement.

Related questions

0 votes
    I would really appreciate some help on what seems to be an easy error to fix, I'm a beginner and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I would really appreciate some help on what seems to be an easy error to fix, I'm a beginner and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I would really appreciate some help on what seems to be an easy error to fix, I'm a beginner and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    Between Eclipse/SWT or Netbeans/Matisse, what does either Java GUI editor give you in terms of rapid ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I have a java object with several members. I want to create a small, quick and dirty editor that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I have a java object with several members. I want to create a small, quick and dirty editor that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Can someone please tell me how to import a jar file in eclipse IDE? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Which of these values is returned by read() method is end of file (EOF) is encountered? (a) 0 (b) 1 (c) ... I/O & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of the following matches end of the string using regular expression in java? (a) \z (b) \\ (c ... Regular Expressions of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    What does public int end(int group) return? (a) offset from last character of the subsequent group (b) ... Regular Expressions of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of the below can be used to debug front end of a web application? (a) Junit (b) Fitnesse (c) ... Technologies & Servlet of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    Can abstract keyword be used with constructor, Initialization Block, Instance Initialization and Static Initialization ... Java Select the correct answer from above options...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    The semicolon (;) at the end of the code is the thing which is got me lost. private View. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    The semicolon (;) at the end of the code is the thing which is got me lost. private View. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    The semicolon (;) at the end of the code is the thing which is got me lost. private View. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
...