• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

passing class? PLEASE HELP

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
}


}
 
ryan wayne
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right that is an error on my part should be

public B b; not public B = b;

 
Jimmy Die
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
same with b2 .

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


to many b's...
 
ryan wayne
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks. i'll try it out
[ October 27, 2004: Message edited by: ryan wayne ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic