Hello guys, i have a problem, is there someone can help me?
this is my logic..

public static void Check_Fund(){      

        String header = "Text1,Text2,Text3,FUND_UALFND_1,FUND_UALPRC_1,FUND_UALFND_2,"

                       +"FUND_UALPRC_2,FUND_UALFND_3,FUND_UALPRC_3,FUND_UALFND_4,FUND_UALPRC_4,FUN  D_UALFND_5,FUND_UALPRC_5,"

                       +"Text4,Text5,Text6,Text7";

        String text = "ABC;CDE;EFG;PRMF;0;PRFF;50;PREF;;PRCF;0;PRMP;50;HIJK;;LMNO;PQRST";

        String[] head;

        String[] value;

        String showText = "";

        head = header.split(",");

        value = text.split(";");



        String regex = "\\d+";



        String fund[] = new String[]{"PREF","PRMF","PRFF","PRCF","PRMP","PDFF","PSEF","PSCB","PSMF","PRGC","PRE  P"};

        List<String> list = Arrays.asList(fund);

        for(int i = 0; i < value.length; i++){

            for(String temp : list){

                if(value[i].equals(temp)){                    

                    if(value[i+1].isEmpty() || value[i+1].equals("0")){

                        value[i] = "N";

                        value[i+1] = "000";

                        //head[i] = head[i].replace(head[i].substring(12, head[i].length()), "0");

                        //head[i+1] = head[i+1].replace(head[i+1].substring(12, head[i+1].length()), "0");

                        isi = value[i] + value[i+1];

                    }else if(value[i+1].matches(regex)){

                        if(value[i+1].length()==1){

                            value[i+1] = "00"+value[i+1];

                        }else if(value[i+1].length()==2){

                            value[i+1] = "0"+value[i+1];

                        }

                        isi = value[i] + value[i+1];

                    }

                }

            }

            showText = showText + head[i] +":" + value[i] + System.lineSeparator();

        }

        System.out.println(showText);



    }

And this is the OUTPUT

Text1:ABC
Text2:CDE
Text3:EFG
FUND_UALFND_1:N
FUND_UALPRC_1:000
FUND_UALFND_2:PRFF
FUND_UALPRC_2:050
FUND_UALFND_3:N
FUND_UALPRC_3:000
FUND_UALFND_4:N
FUND_UALPRC_4:000
FUND_UALFND_5:PRMP
FUND_UALPRC_5:050
Text4:HIJK
Text5:
Text6:LMNO
Text7:PQRST

How to make that OUTPUT LIKE THIS??

Text1:ABC
Text2:CDE
Text3:EFG
FUND_UALFND_1:PRFF
FUND_UALPRC_1:050
FUND_UALFND_2:PRMP
FUND_UALPRC_2:050
FUND_UALFND_3:N
FUND_UALPRC_3:000
FUND_UALFND_4:N
FUND_UALPRC_4:000
FUND_UALFND_5:N
FUND_UALPRC_5:000
Text4:HIJK
Text5:
Text6:LMNO
Text7:PQRST

Please help me..i am very stuck about this..

by correcting your code, no doubt.

you didn't post your actual goal, just some code that doesn't do what it's supposed to do. you've also posted an "ideal" output, but you neglect to mention how that output is (logically) built, and why that is the output you need to get.

without that, all we can do is guess

this is what i mean sir, if the head[i] have value[i]= N or head[i] have value[i]= 000 then it statement move down and else if head[i] have value[i]=PRFF or head[i] have value[i]= 050 then is statement move up,
hmm i think it like this, sorry my english is less

this is program to generate data from barcode value to become .DAT File sir,
but i need to sort it especially in head FUND_FND_i and FUND_PRC_i

my focus is how to sort the value[i] if it head[i] is FUND_FND_i and FUND_PRC_i
i have try this way but it using static array, i am stuck to apply that array value in my loop,

public class TestPassArray {
    public static void main(final String[] args) {
        String[][] data = new String[][] {
                new String[] { "N", "000" },
                new String[] { "N", "000" },
                new String[] { "PREF", "070" },
                new String[] { "N", "000" },
                new String[] { "N", "000" },
                new String[] { "PRGC", "030" },
                new String[] { "N", "000" } };

        Arrays.sort(data, new Comparator<String[]>() {
            @Override
            public int compare(String[] entry1, String[] entry2) {
                final String time1 = entry1[1];
                final String time2 = entry2[1];
                return time2.compareTo(time1);
            }
        });

        for (final String[] s : data) {
            System.out.println(s[0] + " " + s[1]);
        }
    }
}

if the head[i] have value[i]= N or head[i] have value[i]= 000

what do you mean by that ?
do you mean if head[i] is N or 000 ?
if not, what does that head[i]have to do with anything? how are head and value linked ?

no sir, head is header it is like FUND_UALFND_1, FUND_UALPRC_1, FUND_UALFND_2, FUND_UALPRC_2 etc, and value is N, 000, PREF, 070, etc,
it is in single loop, thats why i stuck to make it autosorted every barcode i parsed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.