Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String x = (JOptionPane.showInputDialog(". Each patamater should be separated with a ',' and without spaces. (eg. 1,2,3)") + ",");
- int w = 0, a = 0, y = -1;
- for(int i = 0; i < x.length(); i++)
- {
- if(x.charAt(i) == ',')
- {
- w++;
- }
- }
- Double[] z = new Double[w];
- for(int i = 0; i < x.length(); i++)
- {
- if(x.charAt(i) == ',')
- {
- z[a] = Double.parseDouble(x.substring((y + 1), i));
- y = i;
- a++;
- }
- }
- String x = (JOptionPane.showInputDialog(". Each patamater should be separated with a ',' and without spaces. (eg. 1,2,3)") + ",");
- String[] split = x.split(",");
- Double[] z = new Double[split.length];
- int i = 0;
- for (String s : split) {
- if(s.trim().isEmpty()){
- continue;
- }
- try {
- z[i++] = Double.valueOf(s.trim());
- } catch (NumberFormatException e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement