answersLogoWhite

0


Best Answer

There is no difference, other than that declarations in C++ can also initialise the variable in a single instruction.

C example:

int x; // declaration

x=5; // initialisation

C++ example:

int y=5; // declaration and initialisation combined.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

Consider the following:

C++:

int* anArray;

anArray = new int[10];

delete[]anArray;

Java:

int[] anArray;

anArray = new int[10];

The only real difference is the type used to refer to the array. In C++, we use a primitive int pointer, but in Java, we use an int array reference. Note that all integrals are implemented as objects in Java, since there is no concept of a primitive. All this really means is that C++ programmers must return the memory back to the system whereas Java's garbage collection takes care of it for us.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the difference between array declaration in java and c plus plus?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Main difference between Array List and Vector in Java?

List is not sync'd as a vector is.


Create an anonymous array in java?

An anonymous array in Java is just an array with its contents declared at instantiation. Normal array declaration: int[] nums = new int[3]; nums[0] = 0; nums[1] = 1; nums[2] = 2; Anonymous array declaration: int[] nums = new int[] {0,1,2}; The two examples above will each result in the same array.


What is array in structures?

array is used to store the ame datatypes syntex: int array[]=new int[size]; dynamic declaration of array insertion array[1]=20; 2nd way: int array[]={10,20,30}; *important:- int array[20]={20,30,49,....} this way is wrong in java as this is static way and in java all is done dynamically


What are benefits of array in java?

array example in java


What is difference between java 2 and java 5?

They are different versions. Java 5 is newer than Java 2. Think of it like the difference between the Playstation 1 and the Playstation 3.


Major difference between c and java?

Java is object oriented, C is not...


What is the difference between connectivity in java?

kamina


What is difference between connectivity in java?

kamina


Prog to display array element?

Java solutionFortunately, Java has a number of useful functions in the java.util.Arrays class for us.A call to...System.out.println(java.util.Arrays.toString(array));...will print out any array.


How does one initialize a byte array in Java?

One can get information about how to initialize a byte array in java on the website stackoverflow dot com. That website can learn one a lot about java.


What is the main difference between UNIX and JAVA?

Unix is an operating system, Java is a language.


How do you swap rows in 2 dimensional array in Java?

[]temp = array[1] array[2]=array[1] array[1]=[]temp