jas
ARRAY SIZE.
3 Answer(s)      4 years and 8 months ago
Posted in : Java Beginners

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 Pages:
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
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
Array
Array  can we create an array of size 1 lakh in java programming
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
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
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 "
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
Get Array Size
Get Array Size       To calculate length of the given array we have used length property. It returns the length of the given array.          
JSP List Size
of the list. The JSP List Size uses array list object to add the elements and finally... of elements in the array. l.size : The method returns the size list... JSP List Size     
Java get Folder Size
Java get Folder Size       In this section, you will learn how to get the size of specified folder.  In the given example, we are going to show you the size
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
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}; The size of this array will be 5 elements. *There is another way
Get File Size
display the list of array file using for loop. Now in order to evaluate the size... Get File Size      ... in understanding  Get File Size. For this we have a class name" Get File
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: <html> <Script> var arrsize=window.prompt("Enter size of array: "); var
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
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:  ... C Array default values     
Create Array ??
stores list of â??PhoneEntryâ?? objects. Use an array of size (MAXSIZE = 1000...Create Array ??   Question in e-clips program: Part 1. Array Implementation -Create a class called â??PhoneEntryâ?? which can be used to store
Help With an Array
Help With an Array  So what Im trying to do is write an array... trying to do is almost combine the two to create a larger array declaration. The declaration size does not have to be big, I only included 5 names but I can
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
Array element comparison
Array element comparison  I have arrays of Length(L) , width(W) and Height(H) of same size(in length). Here L , W and H are entered by user. Eg:- Assuming size as 5. Therefore ; Array 1 be 10 , 5 , 6 Array 2 be 12 , 6 , 8 Array 3
Binary Search on array
Binary Search on array  What requirement is placed on an array, so that binary search may be used to locate an entry? â?º The array elements must form a heap. â?º The array must have at least 2 entries. â?º The array must
Size of commarea
Size of commarea  hii, What is the size of commarea?   hello, Default size of commarea is 65k
PHP Array Length
size of array before doing any modification to it. Example of array sizeof...PHP Array Length  HI, I am fresher in PHP? So, please suggest the parameters for PHP Array Lengh and how to declare the array length in PHP program
array in javascript - Java Beginners
array in javascript  how to initialize array in javascript and can we increase the size of array later on? is Array class in javascript ? also...://www.roseindia.net/java/javascript-array/index.shtml Hope
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 - Java Beginners
the size of 2D array :"); int i=input.nextInt(); int d[][]=new int[i][i]; int j,k; System.out.println("Enter the values of 2D array of "+i+" * "+i...array  how to determine both the diagonals of a 2-d array? How
Array in java
in memory at fixed size. We can use multiple type array. It can be used in Java, C... many index Arrays. It is not possible to change the size of an Array during...Array in java In following example we will discuss about Array in Java. Array
Two Dimensional array program
Two Dimensional array program  consider a two dimensional array of size mn where both mn are greater than 20.derive a function that can be used to elements of the array such that the last element become the first one
array example - Java Beginners
array example  hi!!!!! can you help me with this question... dependents to Employee that is an array of Dependent objects, and instantiate a five-element array * while this isn't the best practice, there isn't a much better
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
Question in Array Implementation (java) ??!
stores list of â??PhoneEntryâ?? objects. Use an array of size (MAXSIZE = 1000...Question in Array Implementation (java) ??!  Good Morning EveryOne I have Q in Java - and if any One have the Answers please tall me ??!! Question
Java Array Declaration
to set the size of the declared array. for example: int[] array_name... Java Array Declaration       As we declare a variable in Java, An Array variable is declared
Java Array - Java Beginners
Java Array  Q4-Write a program to exchange the nondiognal elements of a two dimensional array A of size NxN without using any other array ie. each a[i][j]with a[j][i] where i is not equal j?   Hi Friend, Please try
SUBSET ARRAY. - Java Beginners
i will have to do the linear search 20 times as the size of the array is 20...SUBSET ARRAY.  Hi! My question is "How can we search the elements from one array in the other?, I did the linear search 1 time starting from A[i
Java array in currency converter
conversion beyond your array size. After the user selects quit from the menu...Java array in currency converter  Hi all, My sister is trying... to learn alongside her. I am quite lost with this multidimensional array. I do
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
JSP Array Length
. To print the size of array we  use out.print in JSP. array.length( ) ...;% int array[]={2,4,6,8,10}; out.print("Size of Array is: "+array.length... JSP Array Length   
Php Array Implode
;".$entity; ?> Output size is 4 Array ( [0] => we [1] => all [2... implode function joins all elements of the given array into a single String variable PHP Array Implode Function Example <?php   
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...(System.in); int array[]=new int[5]; System.out.println("Enter Array Elements
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
Java array - Java Beginners
array A of size NxN without using any other array ie. each a[i][j]witha[j][i] where i is not equal j? Q5-write a program to read an array of strings... a program tofind sum of all non dioganal elements of a two dimensional NxN array
PHP Get Array Length
;"black", "wall"=>"white"); echo "Array size with count: ".count($colorList); ?> Output: Array size with count...PHP Get Array Length  To count the array length we use count method

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.