PDA

View Full Version : I dont know anything.



patrick.
20-11-2007, 05:53 PM
I don't know anything about programming, but would like to know the basics, so basically.. Teach me :D

Zak
21-11-2007, 12:40 AM
Google what language you would like to learn.

Much better than asking people on a forum.

patrick.
21-11-2007, 05:36 PM
What's the easiest?

Mentor
23-11-2007, 09:32 PM
Well lets do a quick Java.
Install a nice easy IDE, say javes blueJ since it lets u play with the classes nice and easy.

Creare a new class called "bob"
now a bob class wil lappear on the screen bit, double click it to edit its code, you will see a default bob object is already created for you. With a little common sence its actually pretty obvious whats happening.

For a bit more detail,
First of you have a description which will be commented then you have the classes name, { brackets, and then all the code inside it.
First class bit which will be somthing along the lines of
Public Bob {

}

is just the Constructor, basicly this is called when the class is created, pulled in to existence as to say.

Under that is a normal Method, (function?)

public int sampleMethod(int y)
{
// put your code here
return x + y;
}


A quick break down:

<WhocanUse> <DataType> <methodsName>(){

Who can use, basicly is set to ether public (this can be called from outside the class) or private (this can be called only from within this class)

DataType is what type of data the method returns, if nothing, just set it to void.

methods Name is the methods name, basicly its just what u call it. Then you have the to () brackets. Between this is where you add any paramiters u want your method to take.
So heres an Example method

public void printThis(String text){
System.out.println(this);
}

So its a public method, it returns no output (hence void) ands called print this.
It takes the paramiter text, which is type string. hence is said (String name) if it were a number you may use intiger (int name)

System.out.println(); just tells java to print what evers between the ()'s to the terminal (basicly it just appears so u can see it) Make sure you put "" around text if u use that. But as its a var, its just written straight in.

You define varibkes
<Type> <Name>;

so

int pieCounter;
String favFood;
Boolean likesBeans;

(each line is ended with ;)


Now add the code

public void printThis(String text){
System.out.println(this);
}

in to the bluej class thing u created, now minimise that window, right click the box repsenting the class, select compile, then select create new instance, this will create a instance of the object (another box in the bottom) right click that and u can call the method printThis (well u should be able to)

Call it, give it a string (make sure u use "") and hey presto u have a java class that prints crap.

Play around with it. Use google. Go from there, BlueJ makes it all nice and simple so u can avoid having to do the more complex stuff needed to make it actually run as an app, which in the beginning is somehwat confusing (needing static methods and all that jas)

Play around with it :P This is a off my head ramble of crap explination so expect mistakes.

Want to hide these adverts? Register an account for free!