473,416 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

class or interface expected error

1
I am new in java and need your assistance. i have the code below which keep throwing error "class or interface expected".

Expand|Select|Wrap|Line Numbers
  1. public class Candidates
  2. {
  3. String candidateName;
  4. String candidateAddress;
  5. String candidatePosition;
  6.  
  7.   public candidate()
  8.   {
  9.     candidateName = "Peter";
  10.     candidateAddress = "Aburi";
  11.     candidatePosition = "Driver";
  12.   }
  13.  
  14.   public void display()
  15.   {
  16.     System.out.printIn ("Name"+ candidateName);
  17.     System.out.printIn ("Address"+ candidateAddress);
  18.     System.out.printIn ("Position"+ candidatePosition);
  19.   }
  20.     public static void main (String arg [])
  21.      {
  22.        candidate can = new candidate();
  23.        can.display();
  24.       }
  25.  
  26. }
  27.  
  28.  
Sep 10 '10 #1
2 4319
Nepomuk
3,112 Expert 2GB
Hi!
In the first line, you called your class "Candidates", but the constructor is for a class called "candidate" and in the main function you try to create an object of the type "candidate". You should have the same name at all of these places and traditionally the file should have the same name (with a .java at the end of course).

Greetings,
Nepomuk
Sep 12 '10 #2
Hi ngeywa,
Nepomuk is true.
The name of the class "Constructors" (refer line 1) and the name of the constructor (refer line 7) must be exactly same, and you also need to modify line 22 in the same regard.

Regards,
xploreraj
Sep 12 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: ChrisB | last post by:
Hello All: I have created the following field within a class definition: Class User { // fields private RoleInfo roleInfo = RoleInfo.GetRoleInfo(Thread.CurrentPrincipal.Identity.Name);
5
by: owais | last post by:
Hi, I have a problem, I want to implements Parent class interface methods in child class. for e.g -------------- Test1.vb ---------------- Imports System Imports System.Web.UI Imports...
4
by: rach | last post by:
I just started to learn C++. I copied the following code from a data structure textbook to a ".h" file and couldn't compile it. The code contains three template interfaces. One inherits another. The...
4
by: loserdude84 | last post by:
Hi I keep getting the good old error 'Object Expected Error' on a site I recently built. I am really struggling with this one. Object Expected Error Line 66 <div...
10
Dököll
by: Dököll | last post by:
I don't want you nice guys to waste your too much of your time, and confused me in the process. I am hoping you can explain it to me like I am 2 years old, that's it. Hoping to get a handle...
2
by: audiokarate | last post by:
I have like atleast 15 errors that say class, interface, or enum expected and I have no idea what that means. Can someone tell me what it is and how I might be able to fix it? Thank you. - Manny...
15
by: judge82 | last post by:
I made sure I closed all the bracket, why do i still get the error. on line 360, 424, 425 and 607 Please help /* * ShopCartServletHW3.java *
1
by: finizaini | last post by:
I'm receiving an "Object Expected" Error (Line:309, Char:0). I'm confused as to what is happening.Also, I can't run this code using other browser such as Fire Fox. Thispage only can view using IE....
2
by: tridirk | last post by:
Hi; I am getting a Objceted Expected Error on my forum site. I can't find what is wrong? Line: Char: Error: Object expected Code:0 the site is My SMF Forum
0
by: kirthi kumari | last post by:
i donot find any errors,but for almost 18lines of the code am getting an error saying "class,interface or enum expected error".please look at the code below package NQ; import...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.