• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Coding Issue in Java From Book Introduction To Java Programming And Data Structures

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem with some code I used from the book I'm currently using.  Introduction to Java Programming and Data Structures by Y. Daniel Liang.  I like the book it's just what I needed to relearn Java

This is the code in Eclipse:






And these are the errors

numberOfYears cannot be resolved to a variable

This is the error after running the code[/b]

 
Saloon Keeper
Posts: 8077
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to The Ranch !

When you post code, please UseCodeTags (<- link). It will preserve formatting and add line numbers. I fixed it for you this time.
 
Carey Brown
Saloon Keeper
Posts: 8077
71
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have a typo error in your variable name. Check the spelling carefully.
 
Marshal
Posts: 72612
317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That typo is d*mn*d difficult to see. I am surprised your IDE didn't give you more hints about it. Go back to the original code and look for red marks to the left of the line. Hover your mouse on those red marks and you might get hints about how to correct the problem.

And welcome to the Ranch again.
 
Master Rancher
Posts: 4282
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To find different spellings, use the IDE's find/search function for the misspelled name.  You will see that the search skips over the line where the spelling is different.
With a correct spelling, search will find the line where the variable is declared and all the lines where it is used.
 
This parrot is no more. It has ceased to be. Now it's a tiny ad:
ScroogeXHTML - a fast and small RTF to HTML5 and XHTML converter library
https://coderanch.com/t/742149/ScroogeXHTML-RTF-HTML-XHTML-converter
reply
    Bookmark Topic Watch Topic
  • New Topic