Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

filters

 
Ranch Foreman
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still not sure how to correct these errors can some expert quickly help to resolve all these errors so that we could just focus next things  here...


Thanks much..
 
Saloon Keeper
Posts: 6380
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know what an "import" is in Java? If not, work through the relevant section of Oracle's Java tutorial first. After that: how would you use an import to let the Java compiler know that your code wants to use some class, for example 'Comparator"? If you have worked through the tutorial, you would know this, and be able to change your code accordingly.
 
John Ken
Ranch Foreman
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's amazing when i just added one line of code(import java.util.*) in my Employee java program then i just got 1 error but when i just added ';' in front of this line then i got 10 errors.







F:\Java Training\Java Programs>javac Employee.java
Employee.java:4: error: ';' expected
import java.util.*
                 ^
1 error

F:\Java Training\Java Programs>javac Employee.java
Employee.java:11: error: cannot find symbol
                 .filter(e->e.getAge()>22)
                             ^
 symbol:   method getAge()
 location: variable e of type Employee
Employee.java:12: error: invalid method reference
                 .map(Employee::getName)
                      ^
 cannot find symbol
   symbol:   method getName()
   location: class Employee
Employee.java:23: error: constructor Employee in class Employee cannot be applied to given types;
       Employee e1=new Employee("John",21);
                   ^
 required: no arguments
 found:    String,int
 reason: actual and formal argument lists differ in length
Employee.java:24: error: constructor Employee in class Employee cannot be applied to given types;
       Employee e2=new Employee("Martin",19);
                   ^
 required: no arguments
 found:    String,int
 reason: actual and formal argument lists differ in length
Employee.java:25: error: constructor Employee in class Employee cannot be applied to given types;
       Employee e3=new Employee("Mary",31);
                   ^
 required: no arguments
 found:    String,int
 reason: actual and formal argument lists differ in length
Employee.java:26: error: constructor Employee in class Employee cannot be applied to given types;
       Employee e4=new Employee("Stephan",18);
                   ^
 required: no arguments
 found:    String,int
 reason: actual and formal argument lists differ in length
Employee.java:27: error: constructor Employee in class Employee cannot be applied to given types;
       Employee e5=new Employee("Gary",26);
                   ^
 required: no arguments
 found:    String,int
 reason: actual and formal argument lists differ in length
Employee.java:34: error: invalid method reference
 Comparator<Employee> comp = Comparator.comparing(Employee::getName);
                                                  ^
 cannot find symbol
   symbol:   method getName()
   location: class Employee
Employee.java:35: error: cannot find symbol
var filteredAndSorted = employees.stream()
                       ^
 symbol:   variable employees
 location: class Employee
Employee.java:37: error: cannot find symbol
   .collect(toCollection(() -> new TreeSet<>(comp)))
            ^
 symbol:   method toCollection(()->new Tr[...]comp))
 location: class Employee
10 errors

F:\Java Training\Java Programs>javac Employee.java
Employee.java:4: error: ';' expected
import java.util.*
                 ^
1 error

F:\Java Training\Java Programs>

 
Tim Moores
Saloon Keeper
Posts: 6380
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not surprising at all. If you remove the semi-colon the file is syntactically invalid, and the compiler simply gives up trying to make sense of it. Otherwise it's syntactically correct, but has lots of semantic problems.
 
John Ken
Ranch Foreman
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could some expert please quickly remove all these errors and make my code run successfully?

Thanks much...
 
Marshal
Posts: 68909
275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could, yes, will, no.
 
Tim Moores
Saloon Keeper
Posts: 6380
158
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't take an expert, just someone who is willing to read the advice given here already and apply it.
 
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
Learn to write code others love to read, one example at a time!
java.by-comparison.com
    Bookmark Topic Watch Topic
  • New Topic