473,386 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

what is the best solution to create an array of variable size.

If any body could give me the solution of how to create and array of variable size in java or in c++ (Note: except the linked list concept).
Please!
would be very appriciable Thank you!
Mar 29 '10 #1

✓ answered by Frinavale

Since you've posted this question in the C forum I recommend that you look up malloc.

Java has garbage collection and is quite a bit different. There are quite a few different classes that you can use instead of an array. I recommend you check out the ArrayList class.

-Frinny

3 1491
Frinavale
9,735 Expert Mod 8TB
Since you've posted this question in the C forum I recommend that you look up malloc.

Java has garbage collection and is quite a bit different. There are quite a few different classes that you can use instead of an array. I recommend you check out the ArrayList class.

-Frinny
Mar 29 '10 #2
Banfa
9,065 Expert Mod 8TB
If you are using C++ you should avoid malloc which is a C function.

If you really want to handle the memory allocation yourself then use new. However if you would like all them memory allocation handled for you use a vector<>
Mar 29 '10 #3
Frinavale
9,735 Expert Mod 8TB
Oh my, it's been a long time since I've used C++.
How did I forget that my favorite thing about it, when I was learning it, was the "new" keyword!

Thanks Banfa!

-Frinny
Mar 30 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Steven T. Hatton | last post by:
This is something I've been looking at because it is central to a currently broken part of the KDevelop new application wizard. I'm not complaining about it being broken, It's a CVS images. ...
18
by: Xiangliang Meng | last post by:
Hi. void setValue(int n) { int size = getValueLength(); int buffer_p; if (buffer_p) { ....
3
by: matthurne | last post by:
I'm doing a chapter 12 exercise from Accelerated C++ ... writing a string-like class which stores its data in a low-level way. My class, called Str, uses a char array and length variable. I've...
140
by: Oliver Brausch | last post by:
Hello, have you ever heard about this MS-visual c compiler bug? look at the small prog: static int x=0; int bit32() { return ++x; }
43
by: Mountain Bikn' Guy | last post by:
I have a situation where an app writes data of various types (primitives and objects) into a single dimensional array of objects. (This array eventually becomes a row in a data table, but that's...
17
by: yinglcs | last post by:
Hi, In STL, can I create a variable size but non-growable array? In Java, I can do this: int void f (int size) { int array = new int; // do something with array return array;
5
by: Trapulo | last post by:
Hello, I need to send to a webservice a parameter that is a string containing an XML doc. In this xml, a node value came from a byte array (it's an RSA signature). What is the best way to convert...
20
by: pratap | last post by:
Could someone clarify how could one reduce the size of an executable code during compile time. Could one use specific compile time flag with makefile or is it advisable to go for dynamic linking....
29
by: calvert4rent | last post by:
I need to some sort of data type that will hold a listing of ID's and their counts/frequency. As I do some processing I get an ID back which I need to store and keep an accurate count for how many...
10
by: timor.super | last post by:
Hi all, Imagine I've an array of int : int anArray = new int; I want to extract all the integer that are superior to 500 I can do :
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.