0

When an Double Integer is given and the digits of that integer are pushed into array. How to jumble these digits in the array?

Ayrus
  • 1

1 Answers1

1

When an Double Integer is given

This statement is wrong , As @Mike Kobit mentioned , double is not same as integer , but for an Integer Array

Try this

Integer i[]=new Integer[]{1,2,3,4,5};
List<Integer> list=Arrays.asList(i);
System.out.println(list);  ------> Before Shuffling
Collections.shuffle(list);
System.out.println(list); -------> After shuffling
list.toArray(i);  -----> Convert list back to array

Output

[1, 2, 3, 4, 5] -->Before Shuffling
[1, 3, 4, 2, 5] --> After Shuffling
Community
  • 1
  • 1
Neeraj Jain
  • 7,643
  • 6
  • 34
  • 62
  • if input is a number like Long. Is there a way to shuffle some digits? Eg: Input-->> 12897449879333 and output is -->>12897984349373 – Ayrus Apr 15 '15 at 06:50
  • then create a Array of Long , I strongly suggest you to study [data Types in Java](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html) – Neeraj Jain Apr 15 '15 at 06:53