Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java code help!

 
chad steinacker
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to write a program that reads the first name and last name from the user as two seperate inputs and concantenates the first name and a last name seperated by a space. Displasy in a message dialogue the concantenated name?
Can anyone please help me on this one. Any help is greatly appreciated!!!
Thank You~
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chad,
How about the code snippet below?

No challenge,
Manfred.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chad, post what have you written so far. Let's see where you may be going wrong.
 
chad steinacker
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Manfred Leonhardt:
Hi Chad,
How about the code snippet below?

No challenge,
Manfred.

when I tr and run it I get an error 21 class or interface expeected for the line that begins catch( IOException....
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code doesn't describe a class. It is to be within a method that is part of a class.
 
chad steinacker
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im sorry but im not following what youre saying?
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the error you said you were getting, I would guess that you are either trying to use the code example outside of a class definition or that you have a missing and/or extra "{" or "}" somewhere.
The try-catch construct must be inside of a method definition that is inside of a class definition - the framework for which is in my previous post.
If you are still having difficulties getting the code snippet from Manfred to compile and run, if you were to post exactly what you are trying, I'm sure someone will help point out any mistakes.
Good Luck.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic