An error called outofmemory error is coming up when I am giving nums value > 1. I have underlined where num comes. The strings bla1, bla2 etc, I gave for identifying the error.

 private void generateMouseClicked(java.awt.event.MouseEvent evt) {                                      
        String s = new String();
        String o = new String();
        boolean check = true;
        o = "";
        test.setText("bla-1");
        int g[][] = new int[][] {{1,0,0,0,0,0,4,7,9,1},{0,1,0,0,0,0,10,8,1,2},{0,0,1,0,0,0,9,7,7,9},{0,0,0,1,0,0,2,1,8,10},{0,0,0,0,1,0,1,9,7,4},{0,0,0,0,0,1,7,6,7,1}};
        int b[] =  new int[6];
        int d[] = new int[] {0,0,0,0,0,0,0,0,0,0};
        test.setText("bla0");
        s = input_ph.getText().toString();
        int ph = Integer.parseInt(input_ph.getText().toString());
        int [U]num[/U] = Integer.parseInt(ph_no_nums.getText().toString());
        int ap = 0;

        while(num > 0){
            test.setText("bla");
            for(int i=0;i<6;i++){
                b[i] = Integer.parseInt(String.valueOf(s.charAt(i)));
            }
            for(int i = 0; i < 1; i++) {
                for(int j = 0; j < 10; j++) {
                    for(int k = 0; k < 6; k++){

                        d[j] += b[k] * g[k][j];

                    }
                    if(d[j] >= 10){check = false;}
                }
            }

           test.setText("bla1");
            ph += 1;
            String m = new String();
            String ps = new String();
            StringBuffer sb = new StringBuffer();
            String last = new String();
            m = s;
            last = String.valueOf(ph);
            test.setText("bla2");
            if(last.length()<6){
                for(ap=0;ap<(6-(last.length()));ap++){
                    sb.append('0');
                }
                ps = sb.toString();
                ps = ps.concat(last);
                s = ps;

            }
            else s = last;
            sb = null;
            display_area.setText("hello");
            if(check == true){
                o += m + d[6] + d[7] + d[8] + d[9] + '\t' + s + '\t' + ps + '\t' + last + '\n';
                num = num - 1;

            }
            test.setText("bla3");

        }
        display_area.setText(o);
    }

An error called outofmemory error is coming up when I am giving nums value > 1. I have underlined where num comes. The strings bla1, bla2 etc, I gave for identifying the error.

 private void generateMouseClicked(java.awt.event.MouseEvent evt) {                                      
        String s = new String();
        String o = new String();
        boolean check = true;
        o = "";
        test.setText("bla-1");
        int g[][] = new int[][] {{1,0,0,0,0,0,4,7,9,1},{0,1,0,0,0,0,10,8,1,2},{0,0,1,0,0,0,9,7,7,9},{0,0,0,1,0,0,2,1,8,10},{0,0,0,0,1,0,1,9,7,4},{0,0,0,0,0,1,7,6,7,1}};
        int b[] =  new int[6];
        int d[] = new int[] {0,0,0,0,0,0,0,0,0,0};
        test.setText("bla0");
        s = input_ph.getText().toString();
        int ph = Integer.parseInt(input_ph.getText().toString());
        int [U]num[/U] = Integer.parseInt(ph_no_nums.getText().toString());
        int ap = 0;

        while(num > 0){
            test.setText("bla");
            for(int i=0;i<6;i++){
                b[i] = Integer.parseInt(String.valueOf(s.charAt(i)));
            }
            for(int i = 0; i < 1; i++) {
                for(int j = 0; j < 10; j++) {
                    for(int k = 0; k < 6; k++){

                        d[j] += b[k] * g[k][j];

                    }
                    if(d[j] >= 10){check = false;}
                }
            }

           test.setText("bla1");
            ph += 1;
            String m = new String();
            String ps = new String();
            StringBuffer sb = new StringBuffer();
            String last = new String();
            m = s;
            last = String.valueOf(ph);
            test.setText("bla2");
            if(last.length()<6){
                for(ap=0;ap<(6-(last.length()));ap++){
                    sb.append('0');
                }
                ps = sb.toString();
                ps = ps.concat(last);
                s = ps;

            }
            else s = last;
            sb = null;
            display_area.setText("hello");
            if(check == true){
                o += m + d[6] + d[7] + d[8] + d[9] + '\t' + s + '\t' + ps + '\t' + last + '\n';
                num = num - 1;

            }
            test.setText("bla3");

        }
        display_area.setText(o);
    }

end quote.

when i give the value of num as 1, the program is working and Im able to get the output. but with values greater than 1, the app gets stuck or OutOfMemoryError comes up. Somebody, please help!

while(num > 0){ Never ending story

What happens in this loop? How often does it happen?

while(num > 0){
test.setText("bla");
for(int i=0;i<6;i++){
b[i] = Integer.parseInt(String.valueOf(s.charAt(i)));
}

in that loop, the values at each position of string s is getting into the same position of array b. The string s is different for each iteration of the while loop, as I convert it into int in the loop, increment that int and put it back in the same string s again.

while(num > 0){ Never ending story

Each time I run the loop, I decrement the num value. Hence there should be a situation in which num <= 0.

Each time I run the loop, I decrement the num value. Hence there should be a situation in which num <= 0.

Show mi line, where you decremented num value inside while-loop

in that loop, the values at each position of string s is getting into the same position of array b. The string s is different for each iteration of the while loop, as I convert it into int in the loop, increment that int and put it back in the same string s again.

while(num > 0){      // repeat unless num <=0
test.setText("bla");       // put this string in "test"
for(int i=0;i<6;i++){     // put the integer values of  the first 6 characters of s into the array b
b[i] = Integer.parseInt(String.valueOf(s.charAt(i)));  
}     // num has not changed, nor has s, so do the same thing again. Lather, rinse, repeat

Show mi line, where you decremented num value inside while-loop

its the sixth line from the bottom.

while(num > 0){      // repeat unless num <=0
test.setText("bla");       // put this string in "test"
for(int i=0;i<6;i++){     // put the integer values of  the first 6 characters of s into the array b
b[i] = Integer.parseInt(String.valueOf(s.charAt(i)));  
}     // num has not changed, nor has s, so do the same thing again. Lather, rinse, repeat

while closes only at the last line of the program, each iteration of while goes till the end of the program.

And have we learned something today about using code tags? :) You might have had a useful answer a few days ago - remember, nobody here is likely to paste your code into their editor and reformat it to answer your questions, unless the question is really interesting.
You might also consider including the actual error message. Usually, there's useful information there.

Okay, life's too short to read unformatted code, but if you're getting this for values of num >1, but not num==1, then I'd look for something going wrong in your while loop and sending things out of control when it enters the second iteration. Possibly one of the nested loops is going haywire. That's just a guess though.

formatted code:

private void generateMouseClicked(java.awt.event.MouseEvent evt) {
        String s = new String();
        String o = new String();
        boolean check = true;
        o = "";
        test.setText("bla-1");
        int g[][] = new int[][]{{1, 0, 0, 0, 0, 0, 4, 7, 9, 1}, {0, 1, 0, 0, 0, 0, 10, 8, 1, 2}, {0, 0, 1, 0, 0, 0, 9, 7, 7, 9}, {0, 0, 0, 1, 0, 0, 2, 1, 8, 10}, {0, 0, 0, 0, 1, 0, 1, 9, 7, 4}, {0, 0, 0, 0, 0, 1, 7, 6, 7, 1}};
        int b[] = new int[6];
        int d[] = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
        test.setText("bla0");
        s = input_ph.getText().toString();
        int ph = Integer.parseInt(input_ph.getText().toString());
        int num = Integer.parseInt(ph_no_nums.getText().toString());
        int ap = 0;

        while (num > 0) {
            test.setText("bla");
            for (int i = 0; i < 6; i++) {
                b[i] = Integer.parseInt(String.valueOf(s.charAt(i)));
            }
            for (int i = 0; i < 1; i++) {
                for (int j = 0; j < 10; j++) {
                    for (int k = 0; k < 6; k++) {
                        d[j] += b[k] * g[k][j];
                    }
                    if (d[j] >= 10) {
                        check = false;
                    }
                }
            }
            test.setText("bla1");
            ph += 1;
            String m = new String();
            String ps = new String();
            StringBuffer sb = new StringBuffer();
            String last = new String();
            m = s;
            last = String.valueOf(ph);
            test.setText("bla2");
            if (last.length() < 6) {
                for (ap = 0; ap < (6 - (last.length())); ap++) {
                    sb.append('0');
                }
                ps = sb.toString();
                ps = ps.concat(last);
                s = ps;
            } else {
                s = last;
            }
            sb = null;
            display_area.setText("hello");
            if (check == true) {
                o += m + d[6] + d[7] + d[8] + d[9] + '\t' + s + '\t' + ps + '\t' + last + '\n';
                num = num - 1;
            }
            test.setText("bla3");
        }
        display_area.setText(o);
    }

yes, you're right, Line54. Under condition, if (check == true)
double role of "check" boolean value
1. calculate/increase "o" value
2. steering of while loop

may be separate these roles

So unless the condition at line 26 fires num times, this loop never exits.

I might say some words about coding style and clarity and smaller methods here, but I feel I might be seen as nagging a little.

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.