Java basic knowledge to get you started
5 posters
Page 1 of 1
Java basic knowledge to get you started
Integers:
in code they are called int
notice they turn purple because they are a keyword. Ca store a value of a method, object, or a number with no decimal.
EX:
Boolean:
called boolean in code. can store a value of true or false.
useful for certain things.
EX:
String:
called String in code. Don't turn purple because they are a different kind of a value. They store letters. Used for outputting messages.
EX:
Float:
used as a decimal number. after their value put an F
EX:
Now on to coding.
To start your first class do this
That's all for now.
in code they are called int
notice they turn purple because they are a keyword. Ca store a value of a method, object, or a number with no decimal.
EX:
- Code:
int i = 1;
Boolean:
called boolean in code. can store a value of true or false.
useful for certain things.
EX:
- Code:
boolean flag = false;
String:
called String in code. Don't turn purple because they are a different kind of a value. They store letters. Used for outputting messages.
EX:
- Code:
String s = "I am so sexy!";
Float:
used as a decimal number. after their value put an F
EX:
- Code:
float f = 10F;
Now on to coding.
To start your first class do this
- Code:
class sexy {
public static void main(String args[]) {
}
}
- Code:
class sexy {public static void main(String args[]) {
String s = "I am sexy!";
System.out.printf("%s \n", s);
}
}
That's all for now.
Last edited by TheOnly1ne on Tue Oct 25, 2011 3:12 pm; edited 3 times in total
TheOnly1ne- Member
- Posts : 10
Join date : 2011-10-20
Location : I'm in your window.
Re: Java basic knowledge to get you started
Might want to tell them how to start a class
- Code:
class apples{
public static void main(String[] args){
System.out.println("Hello World!");
}
}
breakyorself- Member
- Posts : 60
Join date : 2011-10-19
Re: Java basic knowledge to get you started
Good job so far. I just recommend going a bit more in depth; For Example explain the limits of an integer. Here is something you might use:
An integer is only 0-255 this is because it is a one byte binary number. If you know binary then you know a one byte(8 bit) number is at most 256, I won't go into detail about that, but that is an 1 byte number. In the span 0-255 we include 256 numbers, so it makes sense.
For those of you that don't know binary I will put up a tutorial later, but in simplest form it is the only language computers can read. All cade is broken down into it when executed.
An integer is only 0-255 this is because it is a one byte binary number. If you know binary then you know a one byte(8 bit) number is at most 256, I won't go into detail about that, but that is an 1 byte number. In the span 0-255 we include 256 numbers, so it makes sense.
For those of you that don't know binary I will put up a tutorial later, but in simplest form it is the only language computers can read. All cade is broken down into it when executed.
Static_boy123- Helper
- Posts : 32
Join date : 2011-10-19
Age : 25
Location : Eclipse Indigo
Re: Java basic knowledge to get you started
ok say im using a while loop... and at the end of said loop i want it to change the value of a boolean from false to true or the other way around... how would i go about doing that
Re: Java basic knowledge to get you started
Static_boy123 wrote:Good job so far. I just recommend going a bit more in depth; For Example explain the limits of an integer. Here is something you might use:
An integer is only 0-255 this is because it is a one byte binary number. If you know binary then you know a one byte(8 bit) number is at most 256, I won't go into detail about that, but that is an 1 byte number. In the span 0-255 we include 256 numbers, so it makes sense.
For those of you that don't know binary I will put up a tutorial later, but in simplest form it is the only language computers can read. All cade is broken down into it when executed.
Yet i've set integers to numbers well into the thousands with no repurcussions...?
groxmapper- Member
- Posts : 27
Join date : 2011-10-24
Re: Java basic knowledge to get you started
Nevermind me I am just thinking in two languages at once.groxmapper wrote:Static_boy123 wrote:Good job so far. I just recommend going a bit more in depth; For Example explain the limits of an integer. Here is something you might use:
An integer is only 0-255 this is because it is a one byte binary number. If you know binary then you know a one byte(8 bit) number is at most 256, I won't go into detail about that, but that is an 1 byte number. In the span 0-255 we include 256 numbers, so it makes sense.
For those of you that don't know binary I will put up a tutorial later, but in simplest form it is the only language computers can read. All cade is broken down into it when executed.
Yet i've set integers to numbers well into the thousands with no repurcussions...?
Static_boy123- Helper
- Posts : 32
Join date : 2011-10-19
Age : 25
Location : Eclipse Indigo
Re: Java basic knowledge to get you started
You would put the boolean into the while loop like thisthe undecided t wrote:ok say im using a while loop... and at the end of said loop i want it to change the value of a boolean from false to true or the other way around... how would i go about doing that
- Code:
int i = 0;
while(i < 10) {
boolean flag = true;
i++;
}
TheOnly1ne- Member
- Posts : 10
Join date : 2011-10-20
Location : I'm in your window.
Re: Java basic knowledge to get you started
the undecided t wrote:ok say im using a while loop... and at the end of said loop i want it to change the value of a boolean from false to true or the other way around... how would i go about doing that
- Code:
private int checkWhenFinished = 10;
private boolean isFinished = false;
for(int a = 0; a < 10; a++)
{
//do w/e is needed in the loop
checkWhenFinished--;
}
if(checkWhenFinished == 0)
{
isFinished = true;
}
It's important to keep changing the boolean changing OUT of the loop because then it would return true the first time the loop goes through. I think he wants it to return when the loop has finished, which is what this would do.
groxmapper- Member
- Posts : 27
Join date : 2011-10-24
Re: Java basic knowledge to get you started
Yeah but what he means is to make it only while it is true so maybe more like this:groxmapper wrote:the undecided t wrote:ok say im using a while loop... and at the end of said loop i want it to change the value of a boolean from false to true or the other way around... how would i go about doing that
- Code:
private int checkWhenFinished = 10;
private boolean isFinished = false;
for(int a = 0; a < 10; a++)
{
//do w/e is needed in the loop
checkWhenFinished--;
}
if(checkWhenFinished == 0)
{
isFinished = true;
}
It's important to keep changing the boolean changing OUT of the loop because then it would return true the first time the loop goes through. I think he wants it to return when the loop has finished, which is what this would do.
- Code:
boolean isFinished = false;
int i = 0;
while(i < 10) {
i++;
}
if(i == 10) {
isFinished = true;
}else{
ifFinished = false;
}
TheOnly1ne- Member
- Posts : 10
Join date : 2011-10-20
Location : I'm in your window.
Re: Java basic knowledge to get you started
i mean... look at my code on the on/off light block and you will see what i mean
Re: Java basic knowledge to get you started
where?the undecided t wrote:i mean... look at my code on the on/off light block and you will see what i mean
TheOnly1ne- Member
- Posts : 10
Join date : 2011-10-20
Location : I'm in your window.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum