PDA

View Full Version : New Java is to me



OlyPerson
December 23rd, 2007, 07:17 AM
Ok! So I'm new to Java programming, and, well, programming in general. I have read about one chapter from a book on Python and am reading the Head First book on Java.

I have two questions:
1) In Python it's really easy to input values into the programming by using the variable = input("Blaaaah :" type thing. How do I do this in Java? Or do I just have to assign every variable in the program before compiling?

2) Where can I find some code to study of a pre-written code in Java? I think that along with would be good for my learning, yes?

Thanks!

karusho
December 23rd, 2007, 07:20 AM
When you say 'input', do you mean instance variables or user inputs?

LaRoza
December 23rd, 2007, 07:21 AM
Ok! So I'm new to Java programming, and, well, programming in general. I have read about one chapter from a book on Python and am reading the Head First book on Java.

I have two questions:
1) In Python it's really easy to input values into the programming by using the variable = input("Blaaaah :" type thing. How do I do this in Java? Or do I just have to assign every variable in the program before compiling?

2) Where can I find some code to study of a pre-written code in Java? I think that along with would be good for my learning, yes?

Thanks!

Hello Master Yoda!

0. In Python, you should use raw_input() (until Python 3000). See my wiki in the Python section on getting user input. Java makes user input on the command line tricky. It isn't really suited for it. http://pages.cs.wisc.edu/~cs302/io/JavaIO.html

You must declare the variable before trying to use it.

1. http://math.hws.edu/eck/cs124/javanotes3/source/index.html There is a lot of example code, and I don't know what level you are looking for. Hopefully, that will help. If not, trying googling for Java Source Code Examples.

CptPicard
December 23rd, 2007, 07:22 AM
1) In Python it's really easy to input values into the programming by using the variable = input("Blaaaah :" type thing. How do I do this in Java? Or do I just have to assign every variable in the program before compiling?

Java has no runtime shell like Python does. You won't be actually coding in any language "on the fly" like that anyway, it's always in a proper editor...


Where can I find some code to study of a pre-written code in Java? I think that along with would be good for my learning, yes?

Google. :) Also, go to sourceforge to grab some open source project and read that, once you get more competent.

OlyPerson
December 23rd, 2007, 07:55 AM
Hello Master Yoda!

0. In Python, you should use raw_input() (until Python 3000). See my wiki in the Python section on getting user input. Java makes user input on the command line tricky. It isn't really suited for it. http://pages.cs.wisc.edu/~cs302/io/JavaIO.html

You must declare the variable before trying to use it.

1. http://math.hws.edu/eck/cs124/javanotes3/source/index.html There is a lot of example code, and I don't know what level you are looking for. Hopefully, that will help. If not, trying googling for Java Source Code Examples.

Props for noticing the Yoda reference!
Hmmm, so it is hard to get user input...
I want to make myself a long term project to code in Java to get myself familiar with the language and programming in general, what is a idea for a *relatively* simple program that I could start? Not something simple like calculating the volume of a sphere, but something like a game. Any ideas?

LaRoza
December 23rd, 2007, 09:31 AM
Props for noticing the Yoda reference!
Hmmm, so it is hard to get user input...
I want to make myself a long term project to code in Java to get myself familiar with the language and programming in general, what is a idea for a *relatively* simple program that I could start? Not something simple like calculating the volume of a sphere, but something like a game. Any ideas?

This leaps to mind:

http://ubuntuforums.org/showthread.php?t=500653&highlight=Tetris

The force will be with you...always.

OlyPerson
December 23rd, 2007, 06:51 PM
Wow! Thanks, that should be very useful, and it also has the source code, very nice.
Does anyone have any experience with the Head First book for Java? Are they any good?

samjh
December 23rd, 2007, 10:56 PM
I've heard good reviews about the Head First series, although none about the Java version.

Have you tried Sun's Java tutorial? http://java.sun.com/docs/books/tutorial/
It's very good and up-to-date.

LaRoza
December 24th, 2007, 12:30 AM
Wow! Thanks, that should be very useful, and it also has the source code, very nice.
Does anyone have any experience with the Head First book for Java? Are they any good?

A member of this forum, whose knowledge I admire, recommends that book.

I have no experience with them, and the Sun tutorial is good also.

Try my wiki, I don't have a lot on Java, but they are good.