How to convert an array of strings into an entire array, up, down, bubble, input, output


hellow fellow developer/programmers.

the goal of this program is by asking the user to type any numbers in the inputarea field then he/she will choose any of the three buttons(ascending,descending or bubble). then the product will ouput on the output area field.

now my problem area 1.So i will ask the user to type numbers like this(1,2,3,4,5) with comma then i use split method to neglated comma but it is always string values how can i convert those values into can i contain those values so that i can use it afterwards like puttin those values on those three buttons to use to ascending,descending and bubble sort.3.after the user pick those three buttons how can i transform those those int values into string values so that i can ouput it properly on my outputtextfield.

Im sorry for my grammar.I am new i tried my best to find those answer by searching on google and other forum site but no luck.thanks in advance

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class JavaGui205 extends JPanel

    final JTextField inputarea,outputarea;
    final JButton asc,desc,bubble;
    int getsd;


      //initialize textfield and buttons
      inputarea=new JTextField("Inputarea",20);
      outputarea=new JTextField("Outputarea",20);
      asc=new JButton("Ascending");
      desc=new JButton("Descending");
      bubble=new JButton("BubbleSort");

      //adding function on fields
      inputarea.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)

                String sd=inputarea.getText();
                String[] inputArray=sd.split(",\\s*");


      //ascending function
      asc.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)


      //adding to frame


  public static void main(String[]args)
      JFrame frame = new JFrame("WTF");
      frame.add(new JavaGui205());


how to convert string array into integer

If that is your question then what is the point of the rest of the description of the problem? It is not relevant how you get the data to populate the String Array. All that is relevant is that you have an Array of Strings that represents numbers.

So learn to simplify the problem and don't make your question so confusing.

You need to convert each String to an Integer and you can use the Integer.parseInt(...) method to do this. Something like:

String[] values = ...
int[] numbers = new int[values.length];

for (int i = 0; i < values.length; i++)
    numbers[i] = Integer.parseInt( values[i] );

When you simplify the question then you can simplify the answer because you only concentrate on one thing, not the entire application.