This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Grokking Bitcoin and have Kalle Rosenbaum on-line!
See this thread for details.
Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization 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
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

Head First Java, Chapter 10, "Be The Compiler"  RSS feed

 
Greenhorn
Posts: 19
Java jQuery Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm learning Java from Head First Java book and I'm currently on chapter 10's "Be The Compiler".
According to the "Solution" in the book, I should get this output:




From this code:



However I keep getting this error message:


It seems like the compiler mistakenly took this part as a method, while it was meant to be a constructor:


Did I miss something here?

Thanks.
 
Marshal
Posts: 13443
222
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you have a couple of misplaced closing braces. See the fixed code here: https://repl.it/@jlacar/RanchBeTheCompiler
 
Joshua Soeng
Greenhorn
Posts: 19
Java jQuery Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Yes, you have a couple of misplaced closing braces. See the fixed code here: https://repl.it/@jlacar/RanchBeTheCompiler



Oh the code's changed a lot from the original in the book.
Thank you very much for your help Junilu, now it's clear.
 
Junilu Lacar
Marshal
Posts: 13443
222
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Joshua Soeng wrote:Oh the code's changed a lot from the original in the book.


Not that much, really. I just added the missing closing braces and reformatted the code. Had to remove a public declaration, too, but pretty much that was it.
 
Ranch Hand
Posts: 393
8
BSD Debian Open BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OT:
@Junilu
I just open an account on https://repl.it but doesn't  work for me actually
1. meanwhile their editor loads i can type on editor and the editor hods what i have typed as is normal to be (look at pic)
2. when the editor finish loading and click to enter(in editor) or in CLI  i get ever a black screen  like that in pic and have no way to get it work you have noticed something similar?
3. The only way is to close the tab and repeat  from 1.

I'm on an old Ubuntu 10.04  LTS distro with Firefox 45.0.2

TIA
Repl.it-RanchBeTheCompiler-2-Mozilla-Firefox_057.png
[Thumbnail for Repl.it-RanchBeTheCompiler-2-Mozilla-Firefox_057.png]
meanwhile editor is loading
Repl.it-RanchBeTheCompiler-2-Mozilla-Firefox_056.png
[Thumbnail for Repl.it-RanchBeTheCompiler-2-Mozilla-Firefox_056.png]
after editor is loaded and i click to enter (in editor or in CLI)
 
Junilu Lacar
Marshal
Posts: 13443
222
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harry, you could just copy the code from there and run it locally on your machine.
 
Harry Kar
Ranch Hand
Posts: 393
8
BSD Debian Open BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Harry, you could just copy the code from there and run it locally on your machine.


Yeah i know but I just thought were a good idea having a web REPL for those cases  i were far of my machine but  ... as i referred actually that site not  worked for me dunno why that's the reason i did the question if happens have you noticed something similar

PS:
1. sorry my silliness but I assumed that's a Web REPL right? o miss something?
2. The only logical option i can thing about that failure is my system oldness but ... is strange enough
 
Junilu Lacar
Marshal
Posts: 13443
222
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harry, the only thing I can suggest is that you try a different browser. Opera or Chrome perhaps? I use Chrome on my Mac and have had no problems with repl.it.

Hope that helps.
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!