PDA

View Full Version : learning Java


bin
06-17-2006, 09:56 AM
hi
Whats the best way to learn java?As i hav never done any progamming before exsept html ect

thanks

bin

Spookster
06-17-2006, 08:13 PM
I would suggest playing around with javascript for starters. They are not the same thing of course but you can learn some of the basics using that and then move over to learning how to work with Java.

DELOCH
06-23-2006, 04:35 AM
Spook, what you told him totally messed me up... not to be rude but when I started from javascript not only was it hard, but also it did not look anything like java...

try java from going from simple:

class TestApp { //begins a java file that has to be called TestApp
public static void main(String[] args) { //(a public stat that cannot return a value)
System.out.println("Hello World"); //Tell compiler to write Hello World
} // end public static void main
} end java code

to really big codes

I would reccomend going to a library and getting a big dictionary on the language and slowly memorizing small parts and experimenting

Spookster
06-23-2006, 09:45 AM
Spook, what you told him totally messed me up... not to be rude but when I started from javascript not only was it hard, but also it did not look anything like java...


So basic programming constructs look nothing alike from javascript to java?

Hmm let's look at that.


For loop in javascript:
for (i = 0; i < 5; i++) {
variable1 = variable2[i];
}

For loop in java:
for (i = 0; i < 5; i++) {
variable1 = variable2[i];
}

If statement in javascript:
if (variable == 10) {
variable2 = 3;
} else {
variable2 = 4;
}

If statement in java:
if (variable == 10) {
variable2 = 3;
} else {
variable2 = 4;
}

Switch statement in javascript:
switch (variable1) {
case 1:
variable2 = 6;
break;
}

Switch statement in java:
switch (variable1) {
case 1:
variable2 = 6;
break;
}


Your'e right my mistake those looking nothing alike. :rolleyes:

You completely missed the point of what I said. Learn the basics of programming with javascript before trying java. With javascript you don't need to learn how to set up classes and be able to compile. With javasript you can get familiar with how to use variables and all the basic contructs in programming and learn the basics of programming before moving on to java.

rpgfan3233
06-23-2006, 06:14 PM
So basic programming constructs look nothing alike from javascript to java?

Hmm let's look at that.


For loop in javascript:
for (i = 0; i < 5; i++) {
variable1 = variable2[i];
}

For loop in java:
for (i = 0; i < 5; i++) {
variable1 = variable2[i];
}

If statement in javascript:
if (variable == 10) {
variable2 = 3;
} else {
variable2 = 4;
}

If statement in java:
if (variable == 10) {
variable2 = 3;
} else {
variable2 = 4;
}

Switch statement in javascript:
switch (variable1) {
case 1:
variable2 = 6;
break;
}

Switch statement in java:
switch (variable1) {
case 1:
variable2 = 6;
break;
}


Your'e right my mistake those looking nothing alike. :rolleyes:

You completely missed the point of what I said. Learn the basics of programming with javascript before trying java. With javascript you don't need to learn how to set up classes and be able to compile. With javasript you can get familiar with how to use variables and all the basic contructs in programming and learn the basics of programming before moving on to java.
Loops, arrays, variable scope, branching, etc. are the same in Java and JavaScript, but as far as actually displaying anything (what's the use of creating something if you can't tell whether it actually works or not?), things are completely different. Also, the most basic programming involves data types. JavaScript does not have int, float, char, etc., only the variable and classes. Here's something that'll work in JavaScript, but not Java:

// start JavaScript
var x = '5';
alert(Math.pow(x, 2)); // displays 25 in an alert box
// end JavaScript

// start Java code
char x = '5';
System.out.println(Math.pow(x, 2)); // displays 2809.0 in the console/terminal
// end Java code


The reason why the Java code does that: the character stored in x is treated as an integer in the pow() method, and the integer value of '5' is 53. 53 squared ( 53^2, or Math.pow(53, 2) ) is 2809. If the op learns NOTHING else, at least he/she should learn about the fact that data types do exist and can have strange results if not properly used.

Spookster
06-23-2006, 06:29 PM
Loops, arrays, variable scope, branching, etc. are the same in Java and JavaScript, but as far as actually displaying anything (what's the use of creating something if you can't tell whether it actually works or not?), things are completely different. Also, the most basic programming involves data types. JavaScript does not have int, float, char, etc., only the variable and classes. Here's something that'll work in JavaScript, but not Java:

// start JavaScript
var x = '5';
alert(Math.pow(x, 2)); // displays 25 in an alert box
// end JavaScript

// start Java code
char x = '5';
System.out.println(Math.pow(x, 2)); // displays 2809.0 in the console/terminal
// end Java code


The reason why the Java code does that: the character stored in x is treated as an integer in the pow() method, and the integer value of '5' is 53. 53 squared ( 53^2, or Math.pow(53, 2) ) is 2809. If the op learns NOTHING else, at least he/she should learn about the fact that data types do exist and can have strange results if not properly used.

You've also missed my point. The OP stated that they have no programming experience but do have HTML experience. The easiest way to get familiar at working with basic programming concepts if you are planning on eventually learning Java is to practice with Javascript.

You and Deloach can't seem to look past things like well

In javascript you would

document.write("Hello World");

but in java it would be:

System.out.println("Hello World");

That's different.

Yes I realize there are differences between Java and Javascript. Matter of fact they are two completely different languages. That is not the point here. The point here is the OP does not know how to program. Instead of diving head first into Java not knowing what a variable, array, scope, loop, conditional statement, etc is they can get familiar with using those with Javascript where all they have to do is write a few lines of code and then open the HTML page in their web browser and oila they can see how it works and learn. Once they get familiar with basic programming concepts they can take on the additional learning curve of java and how to set up a class and how to use the compiler and all the other specifics of java.

Is there any more confusion on my point now?

Brandoe85
06-23-2006, 08:28 PM
Nah, you make perfect sense. The differences that were noted about javascript and java is just syntax. The concept of programming either way is closely related. Sure, they are two completely different languages but yet, you can still pick up the basic concepts of programming not the language.

DELOCH
06-23-2006, 09:18 PM
spook, loops are alike in C++, java, javascript, perl, php, and such

while variables and such are different, you can't say

class TestApp {
var name = ("myName")
document.write(name)
}

but you need to do this instead:

class TestApp {
public static void main(String args[]) {
Object name = "myName";
System.out.println(name);
}
}


too much odd and unusual functons and such

it is easier to go to java from C,C++,C#,J#,J++.J, than Javascript...

sorry if I was mean though :(

Spookster
06-23-2006, 10:18 PM
spook, loops are alike in C++, java, javascript, perl, php, and such



I know I actively program in all of those languages. Well not so much for perl except shell scripting.


while variables and such are different, you can't say

class TestApp {
var name = ("myName")
document.write(name)
}

but you need to do this instead:

class TestApp {
public static void main(String args[]) {
Object name = "myName";
System.out.println(name);
}
}



You are still hung up on syntax. You still don't understand my point? :eek:



it is easier to go to java from C,C++,C#,J#,J++.J, than Javascript...


We will have to agree to disagree then because I disagree with that. For someone who is completely new to programming unless they have someone teaching them how to program using a higher level language like Java or C or C++ then they will have a much larger learning curve than if they sat down and learned basic programming concepts from a simple scripting language like javascript. I am talking about basic programming skills here and you keep getting stuck on syntax. A programmer who wants to be good needs to learn programming and not focus on the language. When I taught Intro to Java Programming and Advanced Java programming in college I made it a point to teach the students to not focus on the language and get hung up on syntax.

Spookster
06-23-2006, 10:20 PM
Nah, you make perfect sense. The differences that were noted about javascript and java is just syntax. The concept of programming either way is closely related. Sure, they are two completely different languages but yet, you can still pick up the basic concepts of programming not the language.

I'm glad somebody understands me. :D People get so hung up on syntax and lose sight of the fact programming and the language used to implement a program are seperate things.

Brandoe85
06-23-2006, 10:44 PM
I'm glad somebody understands me. :D People get so hung up on syntax and lose sight of the fact programming and the language used to implement a program are seperate things.

Even going back to college, I think that was the main difference in most of the programming students. Syntax is the last thing on my mind. What about identifying the problem? How are you going to solve it? Then whichever language you choose to use...make sure you use it, don't type it.

I'm thinking this is why they teach only a few languages in college, you don't need to learn the syntax of every language to become a programmer, once you learn the concepts of programming the rest is just syntax, likely noted in the other posts.

DELOCH
06-24-2006, 05:18 PM
That is correct, ones you undestand the basics of the language, you will not care whether you know the syntax or not, if you know the basics you can start building a program and ones your stuck you can come to codingforums or other forums and ask for help

but I am not good with java, I am learning myself until september(I will get programming practice then)

So.. yeah, for a beginner it would be hard to migrate from javaScript to java, but it is easy from java to javascript :)

I tried seriously got confused