aspose file tools*
The moose likes Beginning Java and the fly likes passing class? PLEASE HELP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "passing class? PLEASE HELP" Watch "passing class? PLEASE HELP" New topic
Author

passing class? PLEASE HELP

ryan wayne
Greenhorn

Joined: Aug 13, 2004
Posts: 9
im having a time conceptual understanding something that seems so simple.

basically if I have a class CLASS A
and it is reading a string that lets say is 100bytes long
and I want to make a structure(class B) like this:
(using substring)
String s1 = to the first 5 bytes
String s2 = to the second 5 bytes
Byte[] = to the last 90 bytes

I want it to pass this 'structure'
to CLASS C and have it be able to
take it and make one long string with it again.

what would you pass to CLASS C ?
create a new instance and pass it a object of CLASS B?

can anyone show me an example?

thank you
[ October 27, 2004: Message edited by: ryan wayne ]
Jimmy Die
Ranch Hand

Joined: Nov 20, 2003
Posts: 97
Hi,


I think you're on the right track. Maybe it would look something like this. Of course more is needed...


class A {

public B = b;

public class A() {

b = new B();
}

public void readStringMethod( ...) {

read string stuff;
b.setFirstString();
b.setSecondString();
b.setByteArray();
////(assign everything in b);

}

}


class C {


public B = b2;

public C(B b3) {

b2 = b3;

}

public String getMyNewString(){

/// concatenate your strings and byte array...

return myString;
}


}


Jimmy Die
ryan wayne
Greenhorn

Joined: Aug 13, 2004
Posts: 9
thank you for your reply,

what is public B = b;
is B the class?

so you mean public class B = b; ?
Jimmy Die
Ranch Hand

Joined: Nov 20, 2003
Posts: 97
Right that is an error on my part should be

public B b; not public B = b;

Jimmy Die
Ranch Hand

Joined: Nov 20, 2003
Posts: 97
same with b2 .

Should be public B b2; not public B = b2.


to many b's...
ryan wayne
Greenhorn

Joined: Aug 13, 2004
Posts: 9
thanks. i'll try it out
[ October 27, 2004: Message edited by: ryan wayne ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing class? PLEASE HELP