Java Welcome to Java Class: Learn Java One Bit at a Time

Click For Summary
The discussion focuses on learning Java programming step by step, emphasizing the need for a compiler and a runtime environment. The Java compiler converts source code into bytecode, which is executed by a Java Virtual Machine (JVM), allowing Java programs to run on any platform. Participants are guided through the installation of the Java J2SE 1.4.2 SDK and the process of compiling and running a simple Java program. Clarifications are provided on terminology, such as the difference between source code and object code, and the function of convenience files for compiling and running programs. The conversation also addresses troubleshooting issues related to running Java applets and classpath configurations.
  • #121
I think you can use classes ByteArrayInputStream and ByteArrayOutputStream, which write bytes to or from byte arrays with streams. Then you can utilize the writeObject() and readObject() methods of the stream classes.
 
Technology news on Phys.org
  • #122
There are two classes, ByteArrayInputStream and ByteArrayOutputStream, that place stream interfaces around a byte[] array.

You can use standard Java serialization, writing to such a ByteArrayOutputStream.

- Warren
 
  • #123
Hello, everyoone, i am a linguist teacher studying math as my second degree,
i don't know computer much, i have a little problem writing a java program to draw graph simultanously to reading raw datafrom a file. graph illustrate data read in.
Can u help give me the code or show me how to code it ? I read only a few pages of java2 self study guides.

I hope what you helps me might help someone who searchs a lot these days but unable to find anything.
Thank you very much.
 
  • #124
boteet said:
Can u help give me the code or show me how to code it ? I read only a few pages of java2 self study guides.

Read some more. I doubt very much that you'll get people writing code for you.
 
  • #125
Sorry, although i read , i still can't have time to to finish it because I busy with teaching, my girlfriend needs it, i see she searched internet a lot. i just nneed hints you can tell so i can tell her then.
I need you just give a bit of help for me, please.
 
  • #126
I'm learning Java bymyself using The complete reference of java 2, fifth edition, Herbert Schildt..

I don't use sun's SDK, instead I'm using eclipse..

I was trying to make a small array thingy and here's the code

public class twod {
public static void main(String args[]) {
int twod [][] = new int [4][5];
int i, j, k = 0;

for (i=0; i < 4; i++)
for (j=0; j < 5; j++) {
twod[j]= k;
k++;

}
for (i=0; i < 4; i++){
for (j=0; j < 5; j++);

System.out.print( twod [j] + " "); System.out.println();

}

}


}



And here's the error...
Exception in thread "main"java.lang.ArrayIndexOutOfBoundsException:5
at arrays.twod.main(twod.java:29)

Which is in bold above...It seems to me that the code is correct, i still don't understand what's wrong with the print code..
 
  • #127
Nomy,

The line "for (j=0; j < 5; j++);", just above your System.out.println() call, is wrong. You should not have a semicolon there; instead, you should have an open brace. The semicolon indicates that the for loop is an empty loop, with nothing inside it.

The problem is that a for loop that increments j from 0 to less-than-5 will actually leave the value 5 in the j variable when it's done. The foor loops runs until the condition fails, and the variable j has to contain the value 5 for the condition to fail.

The System.out.println() call is being made -after- the for loop, since the loop is empty. At that point, j contains 5, and you're accessing the array outside its bounds.

- Warren
 
  • #128
Thanks a lot Chroot, now i understand...
 
  • #129
Your algorithm looks like what you did try to implement than it inadvertently turns out to be like that...:biggrin:

Chroot :wink:, I guess nomy wanted to print out the matrix with a semi-colon unfortunately appeared after the second for-loop as an apparent failure for the program to compile, and an exception is thrown right then to indicate the mistake.
 
  • #130
help!

hi, do u have any idea how i can cover the entire screen including the taskbar with an image as soon as a client starts, till a password is provided by the server? The client should not be able to see anything, not even the taskbar till the administrator provides the right password. This has to be done in java... and soon... can u help?
 

Similar threads

Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 33 ·
2
Replies
33
Views
8K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 13 ·
Replies
13
Views
3K