Re: [Java]Introduction Guide
Quote:
Originally Posted by
Ace
lmao, are u using drJava?
It seems that you have no String.
Add this.
Code:
public class MyFirstTest {
public static void main(String[] args) {
String test ;
test = ("Test One");
System.out.println(test);
}
}
why do you put ("String Here") instead of just "String Here"?
and both of those have no difference at all, proving once again you have no idea what you're talking about.
Code:
String str;
str = "String Here";
System.out.println(str);
is the same as doing
Code:
String str = "String Here";
System.out.println(str);
or
Code:
System.out.println("String Here");
Re: [Java]Introduction Guide
wth are u talking about Generic?
It works both ways..
Re: [Java]Introduction Guide
Quote:
Originally Posted by
Ace
wth are u talking about Generic?
It works both ways..
WOAH NO WAY, Kind of like what I just said? You pointlessly put () around your strings, and told him to replace his thing with yours that is exactly the same thing.
Re: [Java]Introduction Guide
How is this code wrong? I had one error but it was at the end...
Code:
String[] test = { "I'm" , "going", "to", "give", "you", "what", "you", "need" };
for (int i = 0; i < test.length; i++) {
System.out.println(test[i]);
}
Re: [Java]Introduction Guide
Quote:
Okay, second line says : public static void main(String[] args) {
This line is a must. All programs should have that as the second line (atleast from what my teacher told me.)
I don't even consider myself a tiny bit good to be a teacher and I can tell you that you teacher must be leeching from here because of the amount of stupidity that his sentence (according with you) have.
Totally Lie.
Quote:
And lastly, it has those 2 "}" Like I said before, all codes must end with this.
All codes SHOULDN'T ends with 2 braces. Not even a logical response.
Quote:
PHP Code:
public class MyFirstProgram {
public static void main(String[] args) {
String helloWorld;
helloWorld = ("Hello World!");
System.out.println(helloworld);
}
}
How you dare to attempt to teach if you can't even make something that simple as a "Hello World" with variables works?
Quote:
PHP Code:
public class MyFirstProgram {
public static void main(String[] args) {
String word;
word = IO.getString("Enter word") ;
System.out.println(word);
}
}
Not like it's wrong to use your pre-made thing, but rather use Java's ones. I personally rather using Scanner to obtain the inputs, but make you use a custom one is like... "eehhhh ok, it's only for educational propose not needed, ty.".
Quote:
I'll continue this guide once I get home from school. Hope this helps you begginers.
Noo!! please No!!!
BTW, the reason Zirgon Tutorial is good, is because he is getting it from a tutorial (no doubt), he is just putting some extra words.
Quote:
If you are building a GUI Application, you wouldn't use public static void main(String[] args) and if your program is just a class full of methods you would not need it. Lastly, in cases where you are writing a program that use methods written by you, it will not always be the second "line" in the program as your methods may be written at the top of the program.
Main is the begin of everything at Java even JFrames/Frames applications. one thing are classes/methods another is the main method.
EDIT:
No shit, this thread get moved? D:
Re: [Java]Introduction Guide
Quote:
Originally Posted by
SpankDaHobo
How is this code wrong? I had one error but it was at the end...
Code:
String[] test = { "I'm" , "going", "to", "give", "you", "what", "you", "need" };
for (int i = 0; i < test.length; i++) {
System.out.println(test[i]);
}
Your code seems alittle awkward.
Is that all you put in for your code?
Wait a sec, what are you trying to make the code do? I don't really understand.
This is what I would've done.
PHP Code:
String test ;
test = "I'm going to give you what you need" ;
System.out.println(test.length());
}
Re: [Java]Introduction Guide
Quote:
Originally Posted by
Ace
Your code seems alittle awkward.
Is that all you put in for your code?
Wait a sec, what are you trying to make the code do? I don't really understand.
This is what I would've done.
PHP Code:
String test ;
test = "I'm going to give you what you need" ;
System.out.println(test.length());
}
Code:
String[] test = { "I'm" , "going", "to", "give", "you", "what", "you", "need" };
That is called an array, in this case, an array of Strings named "test"
Code:
for (int i = 0; i < test.length; i++) {
System.out.println(test[i]);
}
That is a "for" statement, it will do whatever FOR the parameters, in this case it will keep going until the variable "i" is equal to the amount of spots in the array.
As for the reason it does not work Spank, I'm not sure, it works fine for me. Whats the error
Re: [Java]Introduction Guide
Quote:
Originally Posted by
Ace
Your code seems alittle awkward.
Is that all you put in for your code?
Wait a sec, what are you trying to make the code do? I don't really understand.
This is what I would've done.
PHP Code:
String test ;
test = "I'm going to give you what you need" ;
System.out.println(test.length());
}
for each? it will work old way too
for(String improatmine : test)System.out.println(improatmine);
Re: [Java]Introduction Guide
Since everyone's being an ass I'll hop in the bandwagon :3
Quote:
And lastly, it has those 2 "}" Like I said before, all codes must end with this.
That is not true. If a the file was an interface or an abstract class then it could end with 1 fancy bracket.
Second of all, you don't need to wrap your Strings around a bracket when setting it to a variable. You'll find yourself doing this when you get to arrays
Code:
new String[] {("I"), ("am"), ("1337")};
In comparison to
Code:
new String[] {"I", "am", "1337"};
I believe i'd prefer the latter
Re: [Java]Introduction Guide
Quote:
Originally Posted by
PinkGatsby
Since everyone's being an ass I'll hop in the bandwagon :3
That is not true. If a the file was an interface or an abstract class then it could end with 1 fancy bracket.
it only ends with 2 because he has his main method.
this is ex of not need 2 braces
public class Beng {
}
Re: [Java]Introduction Guide
Quote:
Originally Posted by
candyman3435
Seriously, java isn't that hard to learn. One can learn the basics in the matter of a few hours.
Hello world skills aren't that impressive!
Re: [Java]Introduction Guide
Ace, where is your explanation for String, arg[], Main, etc etc.
All you've posted now, is a copy paste from countless other tutorials doing the exact same.
heck, you've even forgot what they did not, details.
Re: [Java]Introduction Guide
If I did copy and paste, I would've added a lot more details.
This is just in my point of view of Java.
and alittle of what my teacher told us.
Going to update thread with "if and else" coding.
Re: [Java]Introduction Guide
Quote:
Originally Posted by
eele
He is right. Except for the 76 part... He is up in the 80's right now :).
As for this guide, It is short, but useful to some i guess :)
Re: [Java]Introduction Guide
What's the point of showing a do/while loop before if statements? You should also at least explain a do/while loop.
Here is my quick crash course on a loop lol
A do/while loop is a while loop that is executed as least once. The syntax is do {code here to be iterated}while(boolean)
A while loop has syntax while(boolean) { code here }, and it does the "code here" as long as the boolean is true.
The difference between do/while and a while is that since while is on the bottom, it gets executed at least once.
Benefit for doing loops:
System.out.println(1);
System.out.println(2);
System.out.println(3);
System.out.println(4);
System.out.println(5);
System.out.println(6);
System.out.println(7);
System.out.println(8);
System.out.println(9);
System.out.println(10);
...
or even in C++
cout << 1 << "\n";
cout << 2 << "\n";
...
you can do this in a few lines of code
for (int start = 0; start < (last number); start++) {
System.out.println(start);
}
int start = 0;//needs to be initiated
while(start < lastNumber) {
System.out.println(start);
start++; //increase it by 1, most while loops need some kind of modifier, otherwise it'll stay true.
}