Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
21 May, 2013, 22:04:17 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: Looking for info...about java -  (Read 811 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
nemo
LV9 Veteran (Next: 1337)
*********
Offline Offline

Last Login: 04 April, 2013, 01:12:57
Date Registered: 16 May, 2010, 03:55:30
Posts: 1198

Total Post Ratings: +83

View Profile
« on: 08 March, 2011, 01:49:42 »
0

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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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:

1
2
3
4
5
6
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)
Logged


Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.181 seconds with 32 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.