File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes First Java Program Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "First Java Program" Watch "First Java Program" New topic
Author

First Java Program

Matt Dogg
Greenhorn

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
Rancher

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


Joanne
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 23395

Hi,

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: 799
ok first of all, "m.wattage", i didnt see the method to set that in your
code

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: 2306
There is also a problem in the String concatenation.
Matt Dogg
Greenhorn

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.

Layne


Java API Documentation
The Java Tutorial
 
IntelliJ Java IDE
 
subject: First Java Program
 
Threads others viewed
Confusion in overriding
David Smalley
ListCellRenderer!!!Help!!
Casting ...
De-serialization
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture