Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Tutorial] An Introduction To Java
Index -> Programming, Java -> Java Tutorials
Goto page Previous  1, 2, 3  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Ultra Jugulator




PostPosted: Tue Oct 25, 2005 3:11 pm   Post subject: (No subject)

Good stuff, guys! I am getting really into it. 8)
Sponsor
Sponsor
Sponsor
sponsor
Justin_




PostPosted: 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




PostPosted: 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_




PostPosted: 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




PostPosted: 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




PostPosted: 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_




PostPosted: 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




PostPosted: 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
Sponsor
sponsor
Justin_




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: 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




PostPosted: Thu Jan 24, 2008 6:19 pm   Post subject: RE:[Tutorial] An Introduction To Java

Java SE, standard edition is what you might want Very Happy
DaMeN




PostPosted: Sat Apr 11, 2009 4:02 am   Post subject: RE:[Tutorial] An Introduction To Java

I downloaded from here: https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=jdk-6u13-oth-JPR@CDS-CDS_Developer
and installed it but stil i cant compile, when i write "javac" in the cmd window it says "'javac' is not recognized as an internal or external command, operable program or batch file.".
what shold i do?
wtd




PostPosted: Sat Apr 11, 2009 12:57 pm   Post subject: RE:[Tutorial] An Introduction To Java

You likely need to setup the PATH environment variable.
Display posts from previous:   
   Index -> Programming, Java -> Java Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 3  [ 32 Posts ]
Goto page Previous  1, 2, 3  Next
Jump to:   


Style:  
Search: