Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


(Someone who knows Java) Need help with Java.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
AnthraX1
Advanced Cheater
Reputation: 0

Joined: 07 Nov 2006
Posts: 51

PostPosted: Thu Feb 01, 2007 5:32 pm    Post subject: (Someone who knows Java) Need help with Java. Reply with quote

Yea I am reading the stuff at java.com and I am confused about this part could someone explain in more detail what is what... I am lost especially with the array over an array I do not understand what is 1 and 2 etc I understand arrays just not the double... or at least the example... also the array copy I am confused about that maybye it is the way they named there variables?

heres what I do not understand...




You can also declare an array of arrays (also known as a multidimensional array) by using two or more sets of square brackets, such as String[][] names. Each element, therefore, must be accessed by a corresponding number of index values.

In the Java programming language, a multidimensional array is simply an array whose components are themselves arrays. This is unlike arrays in C or Fortran. A consequence of this is that the rows are allowed to vary in length, as shown in the following MultiDimArrayDemo program:

class MultiDimArrayDemo {
public static void main(String[] args) {
String[][] names = {{"Mr. ", "Mrs. ", "Ms. "},
{"Smith", "Jones"}};
System.out.println(names[0][0] + names[1][0]); //Mr. Smith
System.out.println(names[0][2] + names[1][1]); //Ms. Jones
}
}

The output from this program is:
Mr. Smith
Ms. Jones

Finally, you can use the built-in length property to determine the size of any array. The code

System.out.println(anArray.length);

will print the array's size to standard output.
Copying Arrays
The System class has an arraycopy method that you can use to efficiently copy data from one array into another:
public static void arraycopy(Object src,
int srcPos,
Object dest,
int destPos,
int length)

The two Object arguments specify the array to copy from and the array to copy to. The three int arguments specify the starting position in the source array, the starting position in the destination array, and the number of array elements to copy.
The following program, ArrayCopyDemo, declares an array of char elements, spelling the word "decaffeinated". It uses arraycopy to copy a subsequence of array components into a second array:

class ArrayCopyDemo {
public static void main(String[] args) {
char[] copyFrom = { 'd', 'e', 'c', 'a', 'f', 'f', 'e',
'i', 'n', 'a', 't', 'e', 'd' };
char[] copyTo = new char[7];

System.arraycopy(copyFrom, 2, copyTo, 0, 7);
System.out.println(new String(copyTo));
}
}

The output from this program is:

caffein

_________________
CAn SOMEONE PLESE TEECH ME Hw To HcK I figured out how o donwlad Ceat Egnegine I just can't oPen it! I GET A SYSTEM 43 ERROR IT ANNOYING HELP!
Back to top
View user's profile Send private message
Labyrnth
Moderator
Reputation: 10

Joined: 28 Nov 2006
Posts: 6301

PostPosted: Thu Feb 01, 2007 7:46 pm    Post subject: Reply with quote

Code:
class ArrayCopyDemo {
public static void main(String[] args) {
char[] copyFrom = { 'd', 'e', 'c', 'a', 'f', 'f', 'e',
'i', 'n', 'a', 't', 'e', 'd' };
char[] copyTo = new char[7];

System.arraycopy(copyFrom, 2, copyTo, 0, 7);
System.out.println(new String(copyTo));
}
}


Well it works almost the same way in game programming for displaying frames.

d e c a f f e i n a t e d
0 1 2 3 4 5 6 7 8 9 10 11 12 13
each letter is a frame, there are 13 frames/ thus 13 letters

The code: System.arraycopy(copyFrom, 2, copyTo, 0, 7);
Is saying to start at frame # 2

So if it is wanting it to start at frame #2 it is going to start on c but it will now be frame #0 then print from there 7 frames.
c a f f e i n
0 1 2 3 4 5 6 7

computers count from 0 not 1 like a human.
Back to top
View user's profile Send private message
AnthraX1
Advanced Cheater
Reputation: 0

Joined: 07 Nov 2006
Posts: 51

PostPosted: Tue Feb 06, 2007 11:57 am    Post subject: Reply with quote

Only had to read that ounce ^^ to get it thanks! ... Now the evil double arrays.... I do not understand what the smith and jones are doing under the list of array names is the line below the array declarings the 2nd [] array? Also the way it prints it out I do not understand how the []# + [][] blah prints it out?

class MultiDimArrayDemo {
public static void main(String[] args) {
String[][] names = {{"Mr. ", "Mrs. ", "Ms. "},
{"Smith", "Jones"}};
System.out.println(names[0][0] + names[1][0]); //Mr. Smith
System.out.println(names[0][2] + names[1][1]); //Ms. Jones
}
}

The output from this program is:
Mr. Smith
Ms. Jones

_________________
CAn SOMEONE PLESE TEECH ME Hw To HcK I figured out how o donwlad Ceat Egnegine I just can't oPen it! I GET A SYSTEM 43 ERROR IT ANNOYING HELP!
Back to top
View user's profile Send private message
Labyrnth
Moderator
Reputation: 10

Joined: 28 Nov 2006
Posts: 6301

PostPosted: Tue Feb 06, 2007 1:09 pm    Post subject: Reply with quote

I do not know much java at all, but i have messed with c++ and vb so i can interpret how this works for the most part.

This is just spaced down. You can tell this by it doesnt have the end ;
{{"Mr. ", "Mrs. ", "Ms. "},
{"Smith", "Jones"}};

Really is like this:
{{"Mr. ", "Mrs. ", "Ms. "},{"Smith", "Jones"}};
0 1 2 0 1

Mr. = 0
Mrs. = 1
Ms. = 2

Smith = 0
Jones = 1

On this part: the // Mr. Smith and // Ms. jones are comments. They are not part of the code. This is like a compound array. "Double array or what ever javaj programmers call it."
System.out.println(names[0][0] + names[1][0]); //Mr. Smith
System.out.println(names[0][2] + names[1][1]); //Ms. Jones


names[0]<--Array [0]<--Mr. + names[1]<--Array [0]<--Smith
names[0]<--Array [2]<--Ms. + names[1]<--Array [1]<--Jones
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites