• Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple Starter Java Question  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I've decided to learn Java since being able to program is becoming more and more essential, just graduated and a lot of employers like it. However I've only been at it a couple of weeks and there is one huge thing that is confusing me. To learn I've been watching lectures on my iPad courtesy of the iTunesU which has a programming class from Stanford, it's really good to follow and starts with Karel the Robot, it then uses The Art and Science of Java text book which I have no complaints about. All of their java programs start something like this

-------
import acm.program.*;

public class myprogram extends ConsoleProgram {


public void run () {

int funtimes = readInt("Enter you number");
println (funtimes);


}
}
------


This is fine and makes sense to me, but then every time I get stuck i'll consult a different book or a website ill go and the in its most basic form looks different.....

------

import java.util.Scanner;

Class myprogram {

system.out.println("goodtimes");

-------

I'm sure its something really basic, but before I go any further am I doing something stupid like learning a early version of Java (my art and science of java book looks old) or is it something to do with Applets vs programs? I'm getting fairly competent writing simple programs in the first style but is it redundant?

Any help would be great, and if you've got any suggestions of good websites/books to follow or useful advice for a beginner that would be great.

Thanks a lot


 
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should see if you can look at the code for ConsoleProgram. It most likely provides some helper methods (readInt(), println()). These methods most likely use Scanner and/or the Console class and/or the System.in/System.out streams to do the input and output. Hopefully the book or course will explain what is happening in those methods, and it will probably be very similar to what you have seen in other places.
 
Marshal
Posts: 56610
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!