File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes First Java Program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "First Java Program" Watch "First Java Program" New topic

First Java Program

Matt Dogg

Joined: Mar 01, 2006
Posts: 2

I am trying to write a program that displays the characteristics of a lightbulb, changes and displays the color of the lightbulb, changes and displays wattage of lightbulb, and turns the lightbulb on if it is off. When I compile I am getting four errors. Can someone give me a nudge in the right direction to fix my errors? Thanks.

[ EFH: Added some [ CODE][ /CODE] tags to preserve formatting ]
[ March 01, 2006: Message edited by: Ernest Friedman-Hill ]
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
Do you want to tell us what the errors are and which lines they are on ?

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199


Welcome to JavaRanch!

I can see three errors; there may be more, or one of the messages may be a red herring, which happens some times.

1) on the very first line, you named the class lightbuld, but then later use the correct spelling.

2) In "displaylightbulb", you forgot a "+" between the first string and 'color' in the first println call.

3) Also in the same routine, there's an open brace after the "else", but no matching close brace for it.

For future references: when posting code that won't compile, it's helpful to post the error messages too; it makes it easier on people who'd like to help!

[Jess in Action][AskingGoodQuestions]
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
ok first of all, "m.wattage", i didnt see the method to set that in your

or m.Color for that matter...

yeah you have methods that modify these, but none that set them.

you need to make

something along those lines, i hope this helped a little bit

You down with OOP? Yeah you know me!
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
There is also a problem in the String concatenation.
Matt Dogg

Joined: Mar 01, 2006
Posts: 2
That helped a bunch, thanks a lot!!!
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
For future reference, please post the compiler error messages you get. This will help us more easily answer your questions and suggest solutions.


Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: First Java Program
It's not a secret anymore!