• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New to Java, confused

 
windy col
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just started learning Java about 3 days ago. I started from this site http://www.homeandlearn.co.uk/java but got confused on one of the pages but before that I was doing okay. I also tried copying and pasting exercise A directly into Netbeans and kept getting error messages. The website asked for Java and Netbeans 6 package to be installed but the only one available was 7, I don't know if that's why I am not able to get it to work. This website had me install netbeans as well. I was doing fine when there was an example of what the prodcut was supposed to look like but for the below exorcise there was no example and I tried to puut the code in several ways and could not figure it out. I am brand new to this and am trying to learn on my own. Sorry this is so long. I got stuck on this page

http://www.homeandlearn.co.uk/java/java_option_panes.html where it starts with:



Exercise
Input boxes and Message boxes can be formatted further. Try the following for your Input boxes:

showInputDialog("First Name", "Enter Your First Name");

showInputDialog("Family", "Enter Your Family Name");
Exercise
For your Message boxes try this (yours should be on one line):

showMessageDialog(null, full_name, "Name", JOptionPane.INFORMATION_MESSAGE);


Exercise
Instead of JOptionPane.INFORMATION_MESSAGE try these:

ERROR_MESSAGE
PLAIN_MESSAGE
QUESTION_MESSAGE
WARNING_MESSAGE


Thanks,

Windy
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15356
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The page has a complete example about halfway down the page. Did you try typing in that?

The Oracle Java Tutorials are a good set of tutorials for learning Java.
 
Winston Gutkowski
Bartender
Pie
Posts: 10422
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
windy col wrote:I am brand new to this and am trying to learn on my own. Sorry this is so long. I got stuck on this page

Well, at the risk of opening up a can of worms, I'm amazed that any tutorial would be showing you option panes, which are a GUI component, before they even talk about basic control flow. I'm also surprised that they start you out from scratch with Netbeans - but that's an argument for another thread.

My advice: If you don't understand this particular section, but you do follow the one about Scanners, skip it (for now). You don't need option panes to get user input - indeed there are many cases where you can't use them; and personally, I can't remember the last time I did.

HIH

Winston
 
Tyson Lindner
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
Well, at the risk of opening up a can of worms, I'm amazed that any tutorial would be showing you option panes, which are a GUI component, before they even talk about basic control flow.


Agreed with this. I think the tutorial is either too hard or moves you along way too quickly, and instinctively the site looks dated.
 
rai salvador
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think it's too early for you to start with awt's, forms and anything that has to do with gui

better start with the basic java tutorial
 
Campbell Ritchie
Sheriff
Pie
Posts: 49382
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the use of option pane is perfectly acceptable in a Tutorial … if it was written before Scanner was invented.
In those days, keyboard input was much more awkward than it is today, and my 2005 edition of Horstmann and Cornell says that option pane has been replaced by Scanner for keyboard input. That does however suggest the tutorial is ten years out of date.

I also notice the link given uses System.exit(0); at the end of the main() method so as to clean up resources. This suggests a misunderstanding of exiting and of garbage collection to me; I shall join those who recommend using a different learning method.
 
windy col
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I did look at the example halfway down, but maybe because I am brand new at this that's why I couldn't figure it out. I am not sure. Thank you to everyone who replied. I am trying out those other links that were posted for beginners and am going to see if I can get a book from the library that was listed in the beginners section of books on here.


Thanks,

Windy
 
Aaron Shawlington
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Purcell over at caveofprogramming.com has some free video courses (udemy), and the paid ones aren't too expensive. He's very good at explaining everything for beginners, so for example he'd explain what he's clicking on in eclipse as he's adding jars to the class path, whereas some other tutorials would just say "add the soAndSo.jar to the classpath".

I just checked, and "Java for complete beginners" is free at http://www.caveofprogramming.com
 
Campbell Ritchie
Sheriff
Pie
Posts: 49382
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aaron Shawlington wrote: . . . He's very good at explaining everything for beginners, so for example he'd explain what he's clicking on in eclipse as he's adding jars to the class path, . . .
That is hardly a beginner's topic.

I couldn't view the lectures to see whether they are any good.
 
Aaron Shawlington
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Aaron Shawlington wrote: . . . He's very good at explaining everything for beginners, so for example he'd explain what he's clicking on in eclipse as he's adding jars to the class path, . . .
That is hardly a beginner's topic.

I couldn't view the lectures to see whether they are any good.


Well the OP was having problems trying a beginners tutorial because he couldn't even get the correct JDK configured in his IDE. The point is that John doesn't just start with a preconfigured environment and start from there - he explains what he is doing when setting up because an full IDE to a newbie is like putting someone who is just learning to drive into a space shuttle, with its 6 thousand switches, or whatever the number is

I think you probably have to register on udemy as thats where they are hosted (when you click through from his site - or search for them directly), although I know his free samples of his paid-for courses tend to be on youtube, so maybe the entire free courses are too (although there might be code downloads available too - I can't remember). Lemme have a quick look...

... ok, take a peek here: http://www.youtube.com/user/caveofprogramming

As it happens he starts part 1 of Java for complete beginners by saying "I'm going to assume that you have already installed eclipse with the JDK....". But in general he's still a very newbie friendly teacher, in my opinion. Be warned that the sound isn't as great in those early videos of his. Some of the others i've seen seem more polished.

I went through his multithreading one recently (which is also free) and I thought it was a pretty good crash-course. I paid a small amount for his Spring one because there were some modules which i hadn't really used in a while, and I thought it would be more pleasant than reading a hefty tome. There was quite alot of content, so I thought it would be good value for anyone new to spring.


Anyhow, just thought i'd mention him because I only came across him a few weeks ago (i'm at home patching up my weak areas while looking for my first contract role after being a permie for 8 years) and although most of his stuff is a little too basic for my needs, I did think that it would have been good to use his material a few years ago. I'm sure lots of newbies might find him helpful.
 
windy col
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone also suggest a book for someone brand new trying to learn Java? I need beginners level with really no knowledge of Java. I have gone to the suggested links and will also check out Cave of Programming. I tried using Eclipse and found NetBeans easier and BlueJ I tried as well from a course I am watching on Udacity.com. I really don't care for BlueJ. The more sites I go to I seem to end up more confused

I tried to put this into NetBeans and kept getting error messages. This was from http://javatutorialhq.com/java/program-structure/ (It didn't really copy and paste correctly)


class DeskFan {

boolean powerOn = false;
int currentGearSpeed=3;
boolean isOscillating=true;

void turnOn(boolean newVal){
powerOn = newVal; }
void changeGearSpeed(int newVal){

currentGearSpeed = newVal; }
void changeOscillation(boolean newVal){
isOscillating=newVal; }}


Thanks,

Windy
 
Aaron Shawlington
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
windy col wrote:Can anyone also suggest a book for someone brand new trying to learn Java? I need beginners level with really no knowledge of Java. I have gone to the suggested links and will also check out Cave of Programming. I tried using Eclipse and found NetBeans easier and BlueJ I tried as well from a course I am watching on Udacity.com. I really don't care for BlueJ. The more sites I go to I seem to end up more confused

I tried to put this into NetBeans and kept getting error messages. This was from http://javatutorialhq.com/java/program-structure/ (It didn't really copy and paste correctly)


class DeskFan {

boolean powerOn = false;
int currentGearSpeed=3;
boolean isOscillating=true;

void turnOn(boolean newVal){
powerOn = newVal; }
void changeGearSpeed(int newVal){

currentGearSpeed = newVal; }
void changeOscillation(boolean newVal){
isOscillating=newVal; }}


Thanks,

Windy


Looks like a rubbish tutorial (followed the link). The example is incomplete - there is no showState() method on the DeskFan class.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49382
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aaron Shawlington wrote: . . . ... ok, take a peek here: http://www.youtube.com/user/caveofprogramming
. . . .
I only had time to watch one tutorial, which looked good.
 
Winston Gutkowski
Bartender
Pie
Posts: 10422
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
windy col wrote:Can anyone also suggest a book for someone brand new trying to learn Java?

Well, one that's recommended quite a lot here is Head First Java. Also, as someone else mentioned, there are the Java tutorials, which are written and maintained by the same people who you get the language from.

However, I suspect that neither of them will start you out with Netbeans, because you don't need it. If you don't have it, download a copy of Notepad+ (if you're on Windows); and about the only other thing you have to do is set up the JAVA_HOME variable (which either the book or the tutorials should guide you through).
It's slower, and sometimes more frustrating, than working from an IDE (which is what Netbeans is), but it really gives you a full sense of what you're doing, which is (I think) what you need at the moment. It also slows you down, which is also no bad thing at this stage, and forces you to do things step-by-step. This is a complex computer language you're learning, not a new recipe.

There's also our book reviews page: I suggest you try the 'Beginning Java' link - and read it all the way down, because there are lots - and count the horseshoes.

HIH

Winston
 
rai salvador
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aaron Shawlington wrote:
windy col wrote:Can anyone also suggest a book for someone brand new trying to learn Java? I need beginners level with really no knowledge of Java. I have gone to the suggested links and will also check out Cave of Programming. I tried using Eclipse and found NetBeans easier and BlueJ I tried as well from a course I am watching on Udacity.com. I really don't care for BlueJ. The more sites I go to I seem to end up more confused

I tried to put this into NetBeans and kept getting error messages. This was from http://javatutorialhq.com/java/program-structure/ (It didn't really copy and paste correctly)


class DeskFan {

boolean powerOn = false;
int currentGearSpeed=3;
boolean isOscillating=true;

void turnOn(boolean newVal){
powerOn = newVal; }
void changeGearSpeed(int newVal){

currentGearSpeed = newVal; }
void changeOscillation(boolean newVal){
isOscillating=newVal; }}


Thanks,

Windy


Looks like a rubbish tutorial (followed the link). The example is incomplete - there is no showState() method on the DeskFan class.


ok my bad, looks like you want a compilable source code then go in http://javatutorialhq.com/java/example-source-code/
 
David McMonigle
Greenhorn
Posts: 24
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I literally went to the SAME Site to start learning. He actually has an app as well. But I quickly got a little frustrated with him as the language he was using was a bit hard to follow.

Give this site a try, there are videos and tons of code for you to learn:


http://www.newthinktank.com/

also, this book by David Eck is very helpful as well:
http://math.hws.edu/javanotes/

Hope I helped!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic