Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Change Array List to Integer or Double in JAVA Program

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 648
    Answer it

    Hi

     

    How can I change an array list to integer or double?

     

    this is my code and i want show answer like a number and i use it not just print it...

     

    import java.util.*;
    public class JavaApplication28 {
    
        public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
            System.out.println("give me a number:");
            int s = input.nextInt();
            ArrayList a = new ArrayList();
            
              do {
                     a.add(s%2);
                     s = s/2;
            } while (!(s/2 == 0 && s%2 == 0));
              
            
            
                
              
            System.out.println("...................");
            for (int i = a.size()-1; i >= 0; i--) {
                System.out.print(a.get(i));
            }
            System.out.println(" ");
            System.out.println("...................");
        }
        
    }

     

    This is a code to give a number and exchange to binary

     

    and this code just print it and i cant use it

     

    another one::(for get a number and give you mirror type ex: 698 => 896)

     

    import java.util.*;
    public class JavaApplication27 {
    
        
        public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
            ArrayList array = new ArrayList();
            System.out.println("give me a num");
            int x = input.nextInt();
            double y = 0;
            while ( x >= 1) {
                array.add(x%10);
                x = x/10;
                
            }
            //System.out.println(array);
            for (int i = 0; i < array.size(); i++) {
                System.out.print(array.get(i));
            }
          
        }
        
    }
    

    I want to use the mirror type...

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: