SRL Archive - General

Java


Footy

2012-08-10 11:00:48

I was talking to a family friend, who is also a computer programmer, and he said if I want to pursue programming as a career, I need to ditch pascal, and learn java! I'm not going to ditch pascal, but is java a good place to go next? And if so, what would be a good tutorial/site to learn from? I have 0 programming experience beside the pascal script I've learned here.
~Footy

eska

2012-08-10 11:20:03

He's right that pascal usualy won't get you a job.

Java sure is a good thing to learn, but you shouldn't just learn one language.

c#, c, c++, java are the ones to know if you want a job.

But above all you must learn lolcode. It is indispensable in today's market.
http://en.wikipedia.org/wiki/LOLCODE

Frement

2012-08-10 11:24:50

Just with what you have learned here is a good start, general knowledge of program structure is a good thing. If you are good with the logic of how you should do things, then you only need to learn the syntax and methods.

Java is quite easy to grasp, so I'd say it's a good start, but I'd recommend choosing a language you want to learn. If you have some interests, something you want/need to make, then pick a language thats best suited for it.

With Java you can make games/applets for web too, so it's good there. If you want to do websites, you should learn HTML, CSS, JavaScript and PHP/ASP. If you want to develop software, I'd recommend C++ with Qt.

Pick a project you want to do and choose your language. Then get the tools and start making.

My path was: HTML, CSS, JS, PHP, Pascal, C++, VB, Java, C#.

But as I said, think of what you'd like to do and start from there.

Silentcore

2012-08-10 11:28:01

If I'm not mistaken Pascal is supposed to be the introduction to programming languages. But Jave is already a little advance for people who know what they are doing.

Footy

2012-08-10 11:30:25

Well I learned pascal to make bots for runescape, that's why I learned it so easily. I guess making a game would be what I want next, so java it is? What are some good websites/tutorials for java?

eska

2012-08-10 11:31:26

You want to make a game from scratch?

Footy

2012-08-10 11:39:38

I don't really have any specific goals, but making a game would be cool.

cycrosism

2012-08-10 11:47:04

Pascal reached its peak in the 80's. You would be much better off learning Java.

Silentcore

2012-08-10 11:49:05

I don't know if this will help but I got this from a 20 second search at google: http://www.javatutorialhub.com/java-tutorial.html. You can also try your local library and maybe find the book: Java for dummies.

Caotom

2012-08-10 11:50:09

I was actually toying with powerbot the other day, considering learning Java properly in the near future but iDung got me interested in the coding for java bots. If you make the script yourself then it is safe (then again it is still an injection bot/pb client…) ;)
It at least provides a related way of learning the basics of Java.

~Caotom

Footy

2012-08-10 12:11:56

Aight, I'll try that link ucantseeme gave me, thanks!

Sirenia

2012-08-10 12:34:03

C++ for game development :P

Silentcore

2012-08-10 12:52:02

From: Footy
Aight, I'll try that link ucantseeme gave me, thanks!


You helped me, now it's my turn to return the favor you did.

Footy

2012-08-10 12:52:11

I got lost at this, I know it prints something like writeln's, but what's all the other stuff?


class A {
*public static void main(String args[]){
*****System.out.println(“First Java Program”);
*}
}

Silentcore

2012-08-10 12:54:43

From: Footy
I got lost at this, I know it prints something like writeln's, but what's all the other stuff?


class A {
*public static void main(String args[]){
*****System.out.println(“First Java Program”);
*}
}


This is supposed to be like a little test: The "First Java Program" is like the words you would see if you did it right.
Take a look: http://docs.oracle.com/javase/tutorial/getStarted/application/index.html

Footy

2012-08-10 13:26:16

Hmm, so I'd I'm understanding right, a class in kind of like a procedure? It's this bit that I don't understand.


class A {
*public static void main(String args[]){
*

superuser

2012-08-10 13:30:33

I HAVE to learn Java by end of this year, unfortunately. Expectations of my employer :) Luckily tho, I get this paid consultant to assist me. Heh.

eska

2012-08-10 13:57:30

From: Footy
Hmm, so I'd I'm understanding right, a class in kind of like a procedure? It's this bit that I don't understand.


class A {
*public static void main(String args[]){
*



No a class is the blueprint from which individual instances and objects are created. This is very, very important to understand. It's the one of the fundamental features of all Object-oriented programming language.

So for example:
class Pizza {
public void BakePizza(){
//code here...
}
public void EatPizza(){
//code here...
}
}

In this case, the class pizza can be used to make object (pizzas) that can be baked and eaten.
When you make such an object, it's called an 'instance'.

So with the previous example, if I wanted to create a pizza instance I would do:

Pizza myDeliciousPizza = new Pizza(); //new allocate the memory to create a new instance

Great, now I have an instance of pizza called myDeliciousPizza… But.. I can't eat it yet! I need to bake it. This is how you would call the method for that pizza:
myDeliciousPizza.BakePizza();     //We call the methods (a method is a function/procedure)
myDeliciousPizza.EatPizza();

***Note this is code I made up and probably won't compile

Footy

2012-08-10 14:04:24

Wow, I am soo confused. How come pascal came so easily? I guess I'll just read some more tutorials.

mormonman

2012-08-10 14:31:54

From: Footy
Wow, I am soo confused. How come pascal came so easily? I guess I'll just read some more tutorials.


I'd suggest finding some kind of book, or a whole set or tutorials explained by the same person. It helps keep things straight for the beginning. Also, you might want to check out OOP basics before anything else.

NKN

2012-08-10 14:55:51

Get the book: Heads first into Java.

It's really easy to follow and understand. :)

Footy

2012-08-10 14:57:27

The tutorial ucantseeme was good, it was a set of ~20 tutorials, but It seemed to skip things. Ill try a book when i get back home. Which would be easier to learn from my standpoint? C++ or Java? Those are the two languages I am most interested in learning.
E:
From: NKN
Get the book: Heads first into Java.

It's really easy to follow and understand. :)

Ill look for this at my local library, thanks for the recomendation!

NKN

2012-08-10 15:00:14

C++ is good, you should learn both in time, if you want a programming career. C++ can be used with DirectX to make games also, but I'm not entirely sure how that process goes. :)

masterBB

2012-08-10 15:05:24

In pascal you also got classes. It is just not used in pascal script.

A class is a blue print of an object. Let's take tv for example. A tv got functions, procedures, variables etc etc.


class tv{

public int width; // var width of the type integer;
public int height; // var height of the type integer;

public String GetShow(String channel) //function GetShow(channel:String): String;
{ //begin

return 'your show in ' + width + ' by ' + height + ' pixels';
//Result := 'Your show in ' + IntToStr(width) + ' by ' + 'pixels';
}

}

Somewhere else:


class livingRoom{

public tv OurSamsungTV; //here you can see our 'class' we just created

public void WatchTv //procedure watchTV
{ //begin
OurSamsungTV.width = 1024;
OurSamsungTV.height = 768;
System.out.println( GetShow('Discovery channel') );
}

}

Footy

2012-08-10 15:14:17

^ Including the pascal comments definetly made it easier to understand. So if I understand correctly, you would input a string for string channel in the first function, and it would return that sentence based on what channel you inputted?

eska

2012-08-10 15:37:10

From: masterBB


class livingRoom{

public tv OurSamsungTV //here you can see our 'class' we just created

public void WatchTv //procedure watchTV
{ //begin
OurSamsungTV.width = 1024;
OurSamsungTV.height = 768;
System.out.println( GetShow('Discovery channel') );
}

}



Shouldn't it be:

class livingRoom{

public tv OurSamsungTV = new tv(); //here you can see our 'class' we just created

public void WatchTv //procedure watchTV
{ //begin
OurSamsungTV.width = 1024;
OurSamsungTV.height = 768;
System.out.println(OurSamsungTV.GetShow('Discovery channel') );
}

}

masterBB

2012-08-10 15:49:11

From: eska
Shouldn't it be:


Yeah, I know. Completely forgot it.

[XoL]

2012-08-10 16:14:46

ANY programming language is great start and will help you dramatically in learning future languages.

superuser

2012-08-10 16:15:50

From: R4nd0m
ANY programming language is great start and will help you dramatically in learning future languages.


With the exception of Brainfuck. :)

For example, to calculate the first 100 numbers of the Fibonacci sequence:

+++++++++++>+>>>>++++++++++++++++++++++++++++++++++++++++++++
>++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+>
+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[-
<-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<<
-]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]
>[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++
+++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++
++++++++++++++++++++++++++++++++++++++++++++.[-]<<
<<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<
[-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]

masterBB

2012-08-10 16:23:57

A bit more on topic. Java is a very different language than C++, it wouldn't be fair to compare them. C++ is a very powerful programming language where there are almost no limits to it's powers. You got direct access to all the system resources. Java is a language which runs in a JVM, it is not as powerful and you are restricted a lot.

So why would you go for java? Cause java is easier to learn and use. It is that simple, also java will always be cross platform, where as in c++ you have to watch out what you use.

[XoL]

2012-08-10 16:25:33

From: superuser
With the exception of Brainfuck. :)

For example, to calculate the first 100 numbers of the Fibonacci sequence:

+++++++++++>+>>>>++++++++++++++++++++++++++++++++++++++++++++
>++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+>
+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[-
<-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<<
-]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]
>[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++
+++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++
++++++++++++++++++++++++++++++++++++++++++++.[-]<<
<<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<
[-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]


Lol yes, I believe you are right on this one.
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,
I think it would be shorter to write it out in binary.
00110001 00101100 00100000 00110001 00101100 00100000 00110010 00101100 00100000 00110011 00101100 00100000 00110101 00101100 00100000 00111000 00101100 00100000 00110001 00110011 00101100 00100000 00110010 00110001 00101100 00100000 00110011 00110100 00101100 00100000 00110101 00110101 00101100 00100000 00111000 00111001 00101100

Killerdou

2012-08-10 16:27:38

fortran is worse than brainfuck…

superuser

2012-08-10 16:32:35

From: Killerdou
fortran is worse than brainfuck…


Nah, fortran is another algol-like language. Like pascal…

Footy

2012-08-10 16:34:46

From: superuser
With the exception of Brainfuck. :)

For example, to calculate the first 100 numbers of the Fibonacci sequence:

+++++++++++>+>>>>++++++++++++++++++++++++++++++++++++++++++++
>++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+>
+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[-
<-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<<
-]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]
>[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++
+++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++
++++++++++++++++++++++++++++++++++++++++++++.[-]<<
<<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<
[-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]


think ill pass on that one…

superuser

2012-08-10 16:39:17

From: Footy
think ill pass on that one…


Wise decision…

Footy

2012-08-10 21:12:04

Thanks so much NKN! The book you reccomended is incredibly easy to follow, and I feel like I've learned so much already! This is my first application, not sure if it compiles, I dont have a compiler on my phone…


Class Writestuff {
public static void main (string[] args) {
int Burgercookedlevel = 0
while burgercookedlevel < 100 {
system.out.println("Burger still cooking! The burger is currently " + BurgerCookedLevel + "Percent finished!");
BurgerCookedLevel = BurgerCookedLevel + 10
}
system.out.println("Burger finished cooking!");
}
}

eska

2012-08-10 21:21:14

From: Footy
Thanks so much NKN! The book you reccomended is incredibly easy to follow, and I feel like I've learned so much already! This is my first application, not sure if it compiles, I dont have a compiler on my phone…


Class Writestuff {
public static void main (string[] args) {
int Burgercookedlevel = 0
while burgercookedlevel < 100 {
system.out.println("Burger still cooking! The burger is currently " + BurgerCookedLevel + "Percent finished!");
BurgerCookedLevel = BurgerCookedLevel + 10
}
system.out.println("Burger finished cooking!");
}




Class Writestuff {
public static void main (string[] args) {
int Burgercookedlevel = 0; //Pesky semi-colon
while (burgercookedlevel < 100) { //pretty sure you need ( ) for the condition, might be wrong but
// it's good standard anyway.
system.out.println("Burger still cooking! The burger is currently " + BurgerCookedLevel + "Percent finished!");
BurgerCookedLevel = BurgerCookedLevel + 10; //Pesky semi-colon, also I think you could use
// the '+=' operator here, it's optional though.
}
system.out.println("Burger finished cooking!");
}
}

Footy

2012-08-10 21:23:08

Whoops, semi colons on almost everything just like pascal! what is the += operator?

eska

2012-08-10 21:28:51

From: Footy
Whoops, semi colons on almost everything just like pascal! what is the += operator?


Say you want to increment a counter, say 'i'.

so you want the value inside 'i', and add 1 to it. Now if you don't know the += operator, you will tell me this can be done with this code:
[highlight'java']i= i + 1;

Now, there is nothing wrong with this. It works, but it is used so frequently that most programming language made it so that you don't need to repeat the name of your variable twice. For our example it doesn't matter much because it's only one letter, but if you had a long variable, you'd lose a bit of time copying it again, and since it's used frequently… it adds up to a lot of time wasted.

So here is the '+=' operator.

i= 1;

Now this example is stupid, because when you want to add only one to a varriable, you can use the '++' operator
So here is the '+=' operator.

++i;
or
i++;

Now I might as well tell you the difference between ++i, and i++.

When you use ++i, the number it returns is incremented right away.
When you use i++, the number it returns is not incremented.

Here's an example:

i= 5;

system.out.println(++i); //This will print '6'.
system.out.println(i); // This will print '6'.

i=5; //lets put back 5 in there to keep it simple.

system.out.println(i++); // This will print 5! Not 6!.
system.out.println(i); // This will print 6.

With i++, the variable is incremented right away, but the number that the operator returns is the 'old' value of the variable.
with ++i, the variable is incremented right away, and the number that the operator returns is the 'new' value of the variable.

Footy

2012-08-10 21:31:09

Alright, thanks! Ill be sure to use this in future applications.

Echo_

2012-08-13 13:37:44

I'm surprised nobody tried to explain classes in terms of PascalScript records, since both are somewhat alike (records have all public members, just like structs in C).

Also remember that Java is alot stricter about capitalization and how things are typed. Pascal is forgiving, you could type:

writeln('Hello, World!');
Writeln('Hello, World!');
WriteLn('Hello, World!');

but in Java, those would be different methods. So make sure you type
System.out.println("Hello, World!");

instead of:
system.out.println("Hello, World!");

because the "system" class does not exist ;)

public class System {
public static PrintStream out;
}

Footy

2012-08-13 20:29:44

^ encountered this error a couple of times! Trying to figure out why its not printing the line, eventually realised java is case-sensitive. Thanks for the tip!

Wyn

2012-08-23 22:29:33

From: eska
But above all you must learn lolcode. It is indispensable in today's market.
http://en.wikipedia.org/wiki/LOLCODE


Your shitting me. I pissed my pants loling at the examples.

Joe

2012-08-23 23:07:30

Java is hard to learn. Start with C++

Footy

2012-08-23 23:24:51

I already bought the beginner java for dummies book, no turning back now!

Echo_

2012-08-24 01:07:19

From: Joe
Java is hard to learn. Start with C++


Java isn't hard compared to C++

Wyn

2012-08-24 02:19:29

From: Joe
Java is hard to learn. Start with C++



Lmfao.

Kasi

2012-08-24 08:42:45

From: Joe
Java is hard to learn. Start with C++


C++ is hard to learn. Start with Java

Vinyl Scratch

2012-08-25 10:52:57

^ Vouch… Just.. Vouch.

But, yeah. Start with Java. If you need help, PM me. I'm no professional, but I know my way around Java.