Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   string array help (eg edit, delete, add, etc..) java (http://www.go4expert.com/forums/string-array-help-eg-edit-delete-add-t26945/)

belial 17Oct2011 03:31

string array help (eg edit, delete, add, etc..) java
program that calls data from an external txt file.....i already have code for reading then sorting the items by their various categories (costP, desc, stockqty, etc) wen i sort one string the others are sorted
however i have nooo idea how to add or remove values to the strings.....i need to be able to search and delete an item from one category and all corresponding values or data on this item will be removed from other strings as well (corresponding items are sorted in parallel) and wen i add an item i need to get the option to add all its corresponding values!! any help will be appreciated thanks...


public class PD

    final static int max = 100; //Arr Size

    public static Scanner keyboard;
    //Arr initialisations
    public static String catList[] = new String[max];
    public static String prodCodeList[] = new String[max];
    public static String desList[] = new String[max];
    public static float costPList[] = new float[max];
    public static float sellPList[] = new float[max];
    public static int qtySkList[] = new int[max];
    public static int qtySdList[] = new int[max];
    public static int reLevList[] = new int[max];
    //public static int holder[] = new int [max];
    public static int count;// arr counter

    public static void main(String args[])

        keyboard = new Scanner(System.in);
        int response = 0;

        loadInput();//Load data from input file

do {
            response = mainMenu();
            if (response == 1)
                response = sortMenu();// response 1 an 2 sorts in asc an desc order resp...already did this
                if (response == 1)
                {  i already wrote the code to sort all the data by anything depending on  what option the user wants

if (response == 3)// Add a values to arrays
            {  i really need help here adding values to the string arrays
if (response == 4)// delete values
            { need help here as well
if (response == 5)// Update information existing in strings
            { i think i would have to use stringbuffer in this case

belial 18Oct2011 00:40

Re: string array help (eg edit, delete, add, etc..) java
ok so i did this to add an element but all it does is replace the last value in the catList with the typed string and adds null values to a new string after the last one...

public static String addcatListElement()
System.out.println("Enter category of new part>");
catList[count++] = keyboard.next();
return categoryList[count];

All times are GMT +5.5. The time now is 09:11.