This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I don't know how to declare a string. My homework assignment is to "declare a string called name setting it equal to my full name and output i using a single println() statement." And "declare 3 strings named fname, mname, and lname, assigning each of my three names to one of the strings. Output my entire name using a single println() statement by using concatentation." Could someone please help me???
Do you know how to declare *any* variable and assign it a value? Do you know how to write a basic "hello world" java program? People will be more than happy to help you , but they won't do your homework for you. If you have specific questions about how to perform a particular task, you'll get more responses. Also, if you can post any code you've written so far, that will also help. Help us help you!!
Joined: May 27, 2002
I do know how to do the "Hello World". I'm only in my 2nd week of programming & I'm not expecting anyone to do my homework for me, it's just that my instructor did not go over how do declare a string. What I have so far is:
[ May 27, 2002: Message edited by: Dirk Schreckmann ]
This is how you declare and define String variables in Java: String someVariableName = "Some text" ; When you want to display the value of this variable using System.out.println, just use the name of the variable instead of the String literal itself: System.out.println( someVariableName ); Hopefully you can now figure out how to do this very same thing three more times using the identifier names and values that you've been instructed to use. Any luck? P.S. I'm surprised if the course book doesn't describe how to do this very thing somewhere in the first couple of chapters.
Thank you very much! I think I was making it harder for myself than it was. It's just that our book goes directly from println to JOptionPane & then to adding integers, but not how to declare character variables. What you suggested worked!
Joined: Dec 10, 2001
...yet another victim of the [expletive deleted] instructors and books that try to force Swing down a brand new programmer's throat... I do not like this trend. Don't be discouraged. Java programming is easy. If your book isn't perfect (and what book could be?), then hit the internet for volumes of free Java learning information (like this great site!). Good Luck.