[Tutorial] An Introduction To Java
Author |
Message |
Ultra Jugulator
|
Posted: Tue Oct 25, 2005 3:11 pm Post subject: (No subject) |
|
|
Good stuff, guys! I am getting really into it. 8) |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Justin_
|
Posted: Sat Mar 11, 2006 1:03 pm Post subject: (No subject) |
|
|
Hello this question is for you wtd. First off this code you wrote:
Java: |
public class Test
{
public static void main (String[] args )
{
Name bobsName = new Name("Bob", "Smith");
printName (bobsName );
}
public static void printName (Name inputName )
{
input. firstName = "Jane";
System. out. println(inputName. fullName());
}
}
|
It doesn't make sense that you would write input.firstName, I think you meant inputName.firstName.
Secondly, you said: "I don't think we ever meant to change bob's first name to jane."
How do you figure that we never meant that?
(if it was written correctly)
inputName.firstName = "Jane"; this line says quite clearly that we are chaning the first name to jane. What do you mean exactly? |
|
|
|
|
|
wtd
|
Posted: Sat Mar 11, 2006 1:59 pm Post subject: (No subject) |
|
|
Justin_ wrote: Hello this question is for you wtd. First off this code you wrote:
Java: |
public class Test
{
public static void main (String[] args )
{
Name bobsName = new Name("Bob", "Smith");
printName (bobsName );
}
public static void printName (Name inputName )
{
input. firstName = "Jane";
System. out. println(inputName. fullName());
}
}
|
It doesn't make sense that you would write input.firstName, I think you meant inputName.firstName.
No, I meant to have it print the full name. That would reflect the change in the first name just fine.
Justin_ wrote: Secondly, you said: "I don't think we ever meant to change bob's first name to jane."
How do you figure that we never meant that?
(if it was written correctly)
inputName.firstName = "Jane"; this line says quite clearly that we are chaning the first name to jane. What do you mean exactly?
Do you understand the concept of private variables? The point here is that any change to the state of an object should go through a well-defined, restrictive interface (a method). The above code just makes the change willy-nilly with no regard for the consequences. |
|
|
|
|
|
Justin_
|
Posted: Sat Mar 11, 2006 4:14 pm Post subject: (No subject) |
|
|
Okay, I'm not following.
Quote:
No, I meant to have it print the full name. That would reflect the change in the first name just fine.
Does that mean you meant to write input.firstName? Even though an input object doesn't exist?
And about the second thing, you said that making variables public has its drawbacks. Not only can you read them, but you can write to them also. Personally, by your example it makes no sense that writing to them is a drawback because no one is going to accidently write: inputName.firstName = "jane" and then wonder afterward how bob's first name became jane.
I understand completely why it is necessary to have a method perform the operations on private variables but I think your example just sounds silly. Your example doesn't express why it might be a drawback, in my opinion. |
|
|
|
|
|
wtd
|
Posted: Sat Mar 11, 2006 4:48 pm Post subject: (No subject) |
|
|
Justin_ wrote: Okay, I'm not following.
Quote:
No, I meant to have it print the full name. That would reflect the change in the first name just fine.
Does that mean you meant to write input.firstName? Even though an input object doesn't exist?
Yes, I typoed. "input" should be "inputName". I did very much mean to print the fullName. |
|
|
|
|
|
wtd
|
Posted: Sat Mar 11, 2006 4:54 pm Post subject: (No subject) |
|
|
When read in context, that example makes perfect sense. I was explaining the dangers of making instance variables public. I then go onto immediately describe how to properly enable access to the variables via accessor methods.
If you have a legitimate beef with my tutorial besides pointing out typoes, feel free to bring it to my attention, but this is seeming very much like trolling, and I do not take well to people cluttering educational threads with trolls. |
|
|
|
|
|
Justin_
|
Posted: Sat Mar 11, 2006 4:56 pm Post subject: (No subject) |
|
|
Okay, my bad for not understanding what you meant before.
Overall it's a good tutorial. |
|
|
|
|
|
wtd
|
Posted: Sat Mar 11, 2006 4:59 pm Post subject: (No subject) |
|
|
Thank you.
Since you've expressed interest in both C++ and Java, I highly suggest you expand your mind beyond the confines of procedural programming.
Something in the functional realm would be a real eye-opener. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Justin_
|
Posted: Sat Mar 11, 2006 5:02 pm Post subject: (No subject) |
|
|
Quote:
If you have a legitimate beef with my tutorial besides pointing out typoes, feel free to bring it to my attention, but this is seeming very much like trolling, and I do take well to people cluttering educational threads with trolls.
I don't mind when you point out my typo's, are you saying you would rather confuse people with typo's?
I'm new so I wasn't totally sure that it was a typo. If you want I can never be inquisitive toward you again?
Personally, I think you've demonized me and are convinced I'm out to get you. You're entirely dillusional though. |
|
|
|
|
|
The_Triangle
|
Posted: Sun Feb 11, 2007 9:10 am Post subject: RE:[Tutorial] An Introduction To Java |
|
|
When I open up the command prompt and direct it to prompt my Helloworld.java file it says, 'Helloworld.java' is not recognized as an internal or external command, operable program or batch file.
What do I do? |
|
|
|
|
|
wtd
|
Posted: Sun Feb 11, 2007 11:17 am Post subject: RE:[Tutorial] An Introduction To Java |
|
|
You first need to compile the file with javac, then run it with the java command. |
|
|
|
|
|
agnivohneb
|
Posted: Thu Jan 24, 2008 6:12 pm Post subject: RE:[Tutorial] An Introduction To Java |
|
|
what should i get SE, EE, ME. I am assuming EE as it is the most downloaded.
Just wondering because this is a old thread. (updates have occurred since then) |
|
|
|
|
|
HeavenAgain
|
Posted: Thu Jan 24, 2008 6:19 pm Post subject: RE:[Tutorial] An Introduction To Java |
|
|
Java SE, standard edition is what you might want |
|
|
|
|
|
DaMeN
|
|
|
|
|
wtd
|
Posted: Sat Apr 11, 2009 12:57 pm Post subject: RE:[Tutorial] An Introduction To Java |
|
|
You likely need to setup the PATH environment variable. |
|
|
|
|
|
|
|