All pastes #11423 Raw Edit

Anonymous

public java v1 · immutable
#11423 ·published 2005-05-10 17:52 UTC
rendered paste body
//the #1 goal here is to take a String, "hello" and convert it to a String[] ARRAY//that returns such as " String[] finalDeal = { "h", "e", "l", "l", "o" }//YES understand about Chars, but this is a unique situation dealing w/Java2d :) //the code as provide provides a working example//the method to do this, has been named "stringStripper" and have been messing for a few hours, since//last night as well but for some reason not figuring it out//Thank youimport java.awt.*;import java.awt.event.*;import java.awt.geom.*;import javax.swing.*;//public class Test2_Graph_Array_Style extends JFrame{private String stringy;     //the initial string desired to be converted into a STRING arrayprivate String[] randStr;private String subbed;      //the 3 examples private String subbed2;private String subbed3;private String[] finalDeal;  //just in case needds to be used for the RETURN element of the methodprivate int length;         //the length of "stringy" - just in case needed in the the methodpublic Test2_Graph_Array_Style()  {            stringy = "hello";            int length = 4;              subbed = stringy.substring(0,1); //this incrementation will occur in the method below via 2 "int"variables            subbed2 = stringy.substring(1,2);            subbed3 = stringy.substring(2,3);                       //the following line outputs "h e l" each on a new line, just as an example            System.out.println(subbed + "\n" + subbed2 + "\n" + subbed3 + "\n The method call is below: \n");                        //stringStripper(stringy);                }    private String stringStripper (String stringy) {        for (int i = 0; i < stringy.length(); i ++) {            int s1 = 0;  //s1 and s2 allow for incrementation of the "substring()"method like Constructor said            int s2 = 1;                        subbed = stringy.substring(s1, s2); //as in the example within the Constructor...            //here is where I've spent hours trying various things such as://randStr[i] = subbed;// String[] autoStr = new String[length](subbed);//randStr[i] = randStr[subbed];            //etc....many other things as well, just not understanding what am doing wrong      System.out.println( subbed );                           s1++;   //increment through each pass         s2++;                 }             return new String (subbed);    }        public static void main (String[] args) {            Test2_Graph_Array_Style test2_Array = new Test2_Graph_Array_Style();                      }  }