I'm trying to create an array of stringbuffers by:
StringBuffer[] rotor={"jndskfnjl","kjbsdbfkj","njkfdn"};
and it shows error "string cannot be converted to stringbuffer". but I can create an array of strings without any problem and I can create declare individual stringbuffers in a similar manner as strings without having to convert them.
Please tell me how I can make an array of stringbuffers.
You would have to go through and create the StringBuffer
objects yourself. It's not an object like String
, where you can create a new one without a constructor; you actually have to instantiate each occurrence.
StringBuffer[] rotor = {new StringBuffer("jndskfnjl"),
new StringBuffer("kjbsdbfkj"),
new StringBuffer("njkfdn")};