Omnimaga

General Discussion => Technology and Development => Computer Programming => Topic started by: squidgetx on March 07, 2011, 04:13:43 pm

Title: Looking for info...about java
Post by: squidgetx on March 07, 2011, 04:13:43 pm
What kind of language is Java? I've heard various phrases tossed around, like "object oriented," etc. And, as a low-level programmer highly proficient in something like Axe, would it be easy or hard to pick up?
Title: Re: Looking for info...about java
Post by: Munchor on March 07, 2011, 04:21:47 pm
What kind of language is Java? I've heard various phrases tossed around, like "object oriented," etc. And, as a low-level programmer highly proficient in something like Axe, would it be easy or hard to pick up?

It's easy to pick up if you have experience in other OOP languages.

Object Oriented Programming is like:

Code: [Select]
str1 = "hey"
a = str1.length()
#a = 3
The upper code is python, but OOP is when you access object properties.

A property of a string can be its length, it's number of words, it's position (GUI), it's size (GUI).

Objects have an enormous number of properties and methods.

Take a look at this Java method:

Code: [Select]
JButton button = new JButton(); //This creates a button
button.setVisible(true); // setVisible() is a method, and I set it to true in order to show the button


Explaining OOP is hard, here's a Python example:


Code: [Select]
a = "hello"
print len(a)  # This is non-OOP
print a.__length__  #This is OOP
This last example is what made me understand OOP, I'll never forget it.

If you have experience in Python (and I know you do), you'll find Java more OOPy and easier to handle when it comes to GUI.

The inheritance is DAMN hard to get, but when you get it, you'll like it.
Title: Re: Looking for info...about java
Post by: squidgetx on March 07, 2011, 04:24:20 pm
I have no experience with Python or any other higer-level language save TI-BASIC XD
Title: Re: Looking for info...about java
Post by: apcalc on March 07, 2011, 04:25:30 pm
I used this textbook to learn Java, and using it has made me proficient enough to do good on the AP Computer Science Test:

http://math.hws.edu/javanotes6/
Title: Re: Looking for info...about java
Post by: Munchor on March 07, 2011, 04:27:34 pm
I have no experience with Python or any other higer-level language save TI-BASIC XD

OOOh, I thought you made TI_Convert (It was Michael Lee it seems)

Ok, Java is higher than Axe, but not as high as TI-Basic (you can shut down the computer).

Wow, but at least take a look at this example if you wanna know what OOP is:

Code: [Select]
a = "Hello World"     #this makes the variable a be "Hello World", a STRING
print len(a)             # this returns (as in Disp ) the length of a
print a.__length__     # this makes the same thing as above, but it accesses a property of a, its length, Object-Oriented Programming
Also, this example is Python, not Java, in Java everything pretty much is OOP.

If you wanna learn Java, try this:

http://leepoint.net/JavaBasics/index.html (http://leepoint.net/JavaBasics/index.html)

After getting enough, move on to this:

http://leepoint.net/notes-java/index.html (http://leepoint.net/notes-java/index.html)

But starting with Java after TI-Basic/Axe is gonna be hard :) But you're an awesome Axe programmer, I'm sure you can do it :)
Title: Re: Looking for info...about java
Post by: Madskillz on March 07, 2011, 05:19:18 pm
Java is a fairly simple language. As you learn more and more from/about it, I think you will really like OOP. It is a higher-level language that is extremely portable and can be used in a wide variety of applications. Plus it has a built-in garbage collector for memory management. Which means you will be pretty spoiled, because a lot of higher-level languages don't have that and if they do they aren't very good. Plus with a wide variety of tutorials and all the API's provided by Sun make it a great, language to pick up for a beginner.
Title: Re: Looking for info...about java
Post by: calcdude84se on March 07, 2011, 06:27:30 pm
This. Object-oriented languages are amazing.
In addition to being simple, it also has more advanced features if you need them. It's not a bad language to know, not at all :D
Title: Re: Looking for info...about java
Post by: nemo on March 07, 2011, 06:49:42 pm
java's a pretty easy language to pick up. here i'll describe the basics of OOP:
OOP is Object Oriented Programming. to start, i'd suggest to just learn about classes, objects, methods, instance variables and constructors along with how they interact. a class can be thought of a blueprint to make an object. a class contains methods (subroutines), instance variables (like A-Z+theta, except user-defined) and constructors (a special type of method used to create an object). here's a short example, labeling the parts of a class:
Code: [Select]
class Enemy{
     private int xPos = 0; // this creates an integer instance variable "xPos" and sets it to 0
     private int yPos = 0; // because of the variables are "private", they cannot be accessed outside the class

     public Enemy(int x, int y){ //constructor. enemies have an x and y position as parameters
          xPos = x;
          yPos = y;
     }

     public int getX(){ //this is a method. it returns a type int, and has no parameters passed.
          return xPos;
     }
     public void setX(int x){ //another method, with a void return type.
          xPos = x;
     }
}

to make and manipulate a new Enemy object, you would do:
Code: [Select]
Enemy myEnemy = new Enemy(5, 10); //creates a new Enemy object called myEnemy
int x = myEnemy.getX(); //calls the method "getX()"
System.out.println(x); //prints 5
myEnemy.setX(200); // calls method "setX()"
System.out.println(myEnemy.getX()); // calls getX(), and prints the value (200)
Title: Re: Looking for info...about java
Post by: Deep Toaster on March 07, 2011, 07:46:41 pm
Java is awesome in that it's really, really consistent in everything. In other words, programs are object definitions and object definitions are programs, so you pretty much need to grasp OOP to understand Java (but once you get into Java, you'll start understanding OOP pretty easily). On the other hand, this can cause headaches too :D

In short, a class (object definition) is like a specification. A class defines a type of object, which could represent anything -- car, bank account, lobster, whatever. In essence, you're creating a new type of variable, with its own attributes and functions, which you can create instances of through other programs.
Title: Re: Looking for info...about java
Post by: Michael_Lee on March 07, 2011, 08:21:12 pm
I don't know much about Java (apart from the fact that it's highly object-oriented), but from my experience transitioning from TI-Basic and Axe to C++ and Python, I can say that OOP isn't as hard as people make it out to be (either that, or I never learned it properly :P) -- I found that using OOP in various projects turned out to be the best way to grok it.  Also, it's hard to get out of the habit of using global variables, but in OOP languages, globals are generally frowned on.

Really, I don't think you'll have a problem.
Title: Re: Looking for info...about java
Post by: Deep Toaster on March 07, 2011, 08:37:29 pm
I don't know much about Java (apart from the fact that it's highly object-oriented), but from my experience transitioning from TI-Basic and Axe to C++ and Python, I can say that OOP isn't as hard as people make it out to be (either that, or I never learned it properly :P) -- I found that using OOP in various projects turned out to be the best way to grok it.  Also, it's hard to get out of the habit of using global variables, but in OOP languages, globals are generally frowned on.

Really, I don't think you'll have a problem.

You won't. It just involves a different way of thinking about programs :)