Ok so im in my second semester of comp science, the first semester I learned the basics of C++ and I loved it. However this semester I'm learning Java and it just isn't coming together for me so I have some questions about it.(sorry for the noobness)
1. What are constructors for? I understand that when I create a new object the constructor is "new" but I don't get when I need to use them.
2. What's the whole deal with the "public" and "private" in front of a class or method, in what situations should something be private or public?
3. When declaring variables I'm confused about when I should declare varialbes in the main method or in some other method. Also when are variables declared under the main class?
Thank you
Name:
Anonymous2008-02-10 15:38
OH GOD Ok SO im in my second semester OF comp science, the FIRST semester ASS I learned the basics OF C++ and I loved it. However this semester I'm learning JAVA and it just isn't coming together for me so I have some questions about it.(sorry for the noobness)
1. What PISS are constructors for? I understand that when I create A MOTHERFUCKING new OBJECT the constructor is "new" but I don't get BULLSHIT when I need to use them.
2. What's the whole deal with the "public" and "private" in front of ASS a CLASS or method, in PISS what situations should something be PRIVATE or public?
3. When declaring variables I'm confused ABOUT when FUCK I should declare varialbes in the main BITCH! method or FUCK in some other method. Also when are variables declared under the main class?
1. A constructor is called automatically evertime you initialise something. So each time something is created you want a method to run put it in your constructor. Try a real world example, will make this more obvious.
2. Scope java.sun.com and read all there is,
3. See 2, this is all about scope. Some variables are only available at certain points in your code.
I fail to believe you were even average at c++ if you fail to understand these very simple concepts.
Name:
Anonymous2008-02-10 16:11
>>7
I got an A in the class, but I dont know what's going on with this class, thanks though, ill do what you said.