0 Members and 1 Guest are viewing this topic.
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?
str1 = "hey"a = str1.length()#a = 3
JButton button = new JButton(); //This creates a buttonbutton.setVisible(true); // setVisible() is a method, and I set it to true in order to show the button
a = "hello"print len(a) # This is non-OOPprint a.__length__ #This is OOP
I have no experience with Python or any other higer-level language save TI-BASIC
a = "Hello World" #this makes the variable a be "Hello World", a STRINGprint len(a) # this returns (as in Disp ) the length of aprint a.__length__ # this makes the same thing as above, but it accesses a property of a, its length, Object-Oriented Programming
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; }}
Enemy myEnemy = new Enemy(5, 10); //creates a new Enemy object called myEnemyint x = myEnemy.getX(); //calls the method "getX()"System.out.println(x); //prints 5myEnemy.setX(200); // calls method "setX()"System.out.println(myEnemy.getX()); // calls getX(), and prints the value (200)
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 ) -- 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.