0

What is array ,one dimensional array in java?

asked 2018-12-04 15:10:47 +0800

preetiagarwal gravatar image preetiagarwal
1

An array is a group of like-typed variables that are referred to by a common name.Arrays in Java work differently than they do in C/C++. Following are some important point about Java arrays. In Java all arrays are dynamically allocated.(discussed below) Since arrays are objects in Java, we can find their length using member length. This is different from C/C++ where we find length using sizeof. A Java array variable can also be declared like other variables with [] after the data type. The variables in the array are ordered and each have an index beginning from 0. Java array can be also be used as a static field, a local variable or a method parameter. The size of an array must be specified by an int value and not long or short. The direct superclass of an array type is Every array type implements the interfaces and. Array can contains primitives data types as well as objects of a class depending on the definition of array. In case of primitives data types, the actual values are stored in contiguous memory locations. In case of objects of a class In Core java training exltech offering training on core java and advance java. Creating, Initializing, and Accessing an Array One-Dimensional Arrays : The general form of a one-dimensional array declaration is type[] var_name

In declaration of array has two components

1.Type and the name.type declares the element type of the array. The element

type determines the data type of each element that comprises the array.

Array of int type, we can also create an array of other primitive data types like

char, float, double..etc.

User defined data type(objects of a class).Thus, the element type for the array

determines what type of data the array will hold.

Instantiating an Array in Java Array is declared, reference of array is created.Actually create or give memory to array, you can create an array like this:Syntax osf array: var-name = new type [size]; Exltech is providing Java training course with practical knowledge on programming.

delete flag offensive retag edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2018-12-04 15:10:47 +0800

Seen: 2 times

Last updated: Dec 04

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More