ARRAY SIZE.

ARRAY SIZE.

View Answers

September 30, 2008 at 10:23 AM

Hi friend,


Do some changes for compile and run the code correctly

int num2= numbers*2;
B.add(num2);


Code :

import java.io.*;
import java.util.ArrayList;


public class CopynDouble1
{
public static void main(String[] param){
try{
BufferedReader n = new BufferedReader(new InputStreamReader(System.in));

ArrayList<Integer> A = new ArrayList<Integer>(); //array A
ArrayList<Integer> B = new ArrayList<Integer>(); //array B

System.out.print("Input number: ");
String userInput = n.readLine(); //read Input;
int numbers = Integer.parseInt(userInput); //integer version of userInput;

while(numbers != 0){
A.add(numbers);
int num2= numbers*2;
B.add(num2);
System.out.println(B); // Don't know how to print array B in this case.
System.out.print("Input number: ");
userInput = n.readLine();
numbers = Integer.parseInt(userInput);
}
}


catch(Exception e){
}
}
}

For read more information :
http://www.roseindia.net/java/

Thanks


September 30, 2008 at 12:01 PM

Hi

B is ur ArraayList Object, So u can.t use any aritmatic operation on that object.

in ur code just modify
while(number !=0){

A.add(number)
B.add(number*2);

}

Thanks
Rajanikant

October 2, 2008 at 2:24 AM

ThankYou Very Much Rajanikant and Deepak.
I can't ThankYou Guys enough for helping me in solving this code.









Related Tutorials/Questions & Answers:
calculate size of array
calculate size of array  Is it possible to calculate the size of array using pointers in Java
ARRAY SIZE!!! - Java Beginners
ARRAY SIZE!!!  Hi, My Question is to: "Read integers from... to initialize the array when you don't know the size of the array. Just to get...). Vector is a growable array. Here no need to define the intial size of ur
Advertisements
ARRAY SIZE. - Java Beginners
ARRAY SIZE.  Thanks, well that i know that we can use ArrayList... the elements in array A. Then doubled array A by multiplying it by 2 and then storing it in array B. But gives me error. import java.io.*; import
create python array of size n
create python array of size n  Hi, I want code to create python array of size n? For example if n=10 then it should create an empty array in python with n size. Thanks   Hi, Following example might be helpful
How do you get the size of an array in Python
How do you get the size of an array in Python  Hi, I want to get the size of my array in Python. How do you get the size of an array in Python? How... and then returns the size of the array. Here is complete program of getting the size
Python create array of size n with value
Python create array of size n with value  Hi, I have to a requirement to create an array with n size and fill it with value 10. How it's possible in Python? Share me code to create array of size n with value in Python. Thanks
Python create array of size n with value 0
Python create array of size n with value 0  Hi, In python I want to create an array with n size and initialize it with 0 value. What is Python code to create array of size n with value 0? Thanks   Hi
JavaScript array size
JavaScript array size     ... you in understanding JavaScript array Size. The code shows you a HTML Page ... is assigned to array [count]. The function show( ) include the variable string return
Create array of random size
Create array of random size In this tutorial, you will learn how to create... the Random class, we have set the random size to array. We have stored... the size of array, the code catch out-of-bounds exceptions and display "
Get Array Size
Get Array Size   ... and the explained you how to get the size of these array.? The array.length... to get size of array in Java?": ADS_TO_REPLACE_4 Here is the full
Array
Array  can we create an array of size 1 lakh in java programming
Array
("Enter Range: "); int size=input.nextInt(); int array[]=new int[size]; System.out.println("Enter Array Elements: "); for(int i=0;i<...Array  How do i insert elements into an array up to a limit from
JSP List Size
of the list. The JSP List Size uses array list object to add the elements and finally... print the size of elements in the array. l.size : The method returns the size... JSP List Size     
in_array
in_array  in_array in php
is _array()
is _array()  is_array() in php   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
is _array()
is _array()  is _array()   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
JavaScript Array undefined
JavaScript Array undefined       Undefined array is a condition that occurred when a user want to print an array element more than the declared size of element that an array
Array in Java
An Array is the static memory allocation that holds a fixed number of values of same type in memory. The size or length of an array is fixed when the array...[] = {50,60,70,80,90};ADS_TO_REPLACE_6 The size of this array will be 5 elements
C Array default values
in Array. The example below contains an array arr of integer type. The maximum size of the array is 4. We have allocated only two values in the array like this:ADS... C Array default values     
Array
Array  how can i use elements of an array in a circular form? that is if the searching of the element reach the last elements of the array, then it will start serching from the begining of the array
Array
Array  is it possible to define array like this..? int[] intArray = new int[] {4,5,6,7,8}; Explain...?   Yes, you can. Java Initialize Array
Array
Array  What if i will not declare the limit index of an array, how will I declare an array and store values with it using loop?   Hi Friend... Scanner(System.in); int array[]=new int[5]; System.out.println("Enter
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  WAP in java to store 6 element in array P and 4 element in array Q. Produce the third arra y R containing all element from p & q
array
array  array memory allocation is dynamic or static in java   Java Arrays have dynamic memory allocation
Size of commarea
Size of commarea  hii, What is the size of commarea?   hello,ADS_TO_REPLACE_1 Default size of commarea is 65k
array
array  create an array in which no element is duplicate. if duplicate then tell to user duplicate. duplicacy is tell to user during when he enter the element
array
array  create an array in which no element is duplicate. if duplicate then tell to user duplicate. duplicacy is tell to user during when he enter the element
array
array  take a 2d array and display all its elements in a matrix fome using only one for loop and ple explain the program in below
array
accepts a pointer to integer which represents an array of integer.After that this method prints the entire of the array numbers to the monitor. include using std::cout; using std::endl; void printArray(int *array, int count
array
array  How to store the results of mysql query in an array... qurey in array: "select distinct(EMPLID)from tblwork where EMPLID not in (select... store the result in array
array
array  wap to calculate reverse of 10 elements in an array?  ...(); } System.out.print("Array is: "); for(int i=0;i<arr.length;i...(); System.out.print("After reversing, Array is: "); for(int i=arr.length-1;i>=0
Array's
Array's  I have to finish an "order page". that checks 2 dropdown boxes and a set of radio buttons and put the results into a set of textboxes, 1 line at a time, then calculate a total. I know I need to create an array, but I'm
array
array  Hi i have array like {1,2,3,4,,5,5,6,6} then how can i... is an example that store some integers into an array and find the occurrence of each number from the array. import java.util.*; public class SearchNumberOccurrence
array
array  how to getting values and storing values in array by using datainputstream?   Hi Friend, Try the following code:ADS_TO_REPLACE_1...("Array Elements are: "); for(int i=0;i<arr.length;i
Array
reserved. Use a one-dimensional array of primitive type Boolean to represent the seating chart of the cinema theater. Initialize all the elements of the array... the corresponding elements of the array to true to indicate that the seat is no longer
Size in FLex
Size in FLex  Hi..... What is the difference between width, explicitWidth, measuredMinWidth, measuredWidth, and percentWidth? please tell me about that difference Thanks
Size in FLex
Size in FLex  Hi... I just want to know about... What happens in measure()? measuredHeight, measuredWidth, measuredMinHeight, measuredMinWidth are set. please give me an example with description... Thanks
Array in C
Array in C  Respected Sir, How can an array be an lvalue, if we can't assign to it? How can I set an array's size at run time? How can I avoid fixed-sized arrays? help me sir
maximum size of arraylist - java
array. If the array list size is very huge, Insertion and removal operations...maximum size of arraylist - java  1.what is the maximum size... and interface?   1) It depend on heap size of machine and heap size depend
Circular array implementation
Circular array implementation  i have 2 arrays of strings with size 7 and 9 respectively. I want my array with size 7 to be circular and copy the strings from other array of size 9 to the array of size 7. When i copy the strings
track file size changes
track file size changes  How to track a change in file size
javascript max size
javascript max size   How to retrive Max size in JavaScript
Servletoutputstream size limit.
Servletoutputstream size limit.  What is the maximum size of ServletOutputStream
Javascript array
the array size from the user Input the array elements from the user display the array elements reverses it and display   Hello Friend, Try this:ADS_TO_REPLACE_1 <html> <Script> var arrsize=window.prompt("Enter size
Servletoutputstream size limit.
Servletoutputstream size limit.  What is the maximum size of ServletOutputStream?   By default size is set to 10MB.You can increase your message size maximum 2000000000 bytes. That is size limit is 2000000000
hibernate.jdbc.batch_size
In this section, you will learn about the hibernate.jdbc.batch_size of the hibernate.cfg.xml.
size of all primitive data
size of all primitive data   java program for to find the size of all primitive data types in java

Ads