Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Write a program to insert an element and in the specific position in the array?



Write a program to insert an element and in the specific position in the array?..

Answer / Chandra Prakash

In Java, you can use the System.arraycopy() method to insert an element at a specific position in an array. Here's a simple example:

```java
public void insertAt(int arr[], int index, int element) {
if (index > arr.length)
System.out.println("Invalid Index");
else {
for (int i = arr.length; i > index; i--)
arr[i] = arr[i - 1];
arr[index] = element;
}
}
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

What are the major data structures used in the following areas : network data model & hierarchical data model?

1 Answers  


What is the advantage of the heap over a stack?

1 Answers  


Define articulation point?

1 Answers  


Is hashmap an array?

1 Answers  


Is queue fifo or lifo?

1 Answers  


What is immutablelist?

1 Answers  


What is hash value of a string?

1 Answers  


Why is the isempty() member method called?

1 Answers  


How memory is reserved using a declaration statement ?

1 Answers  


What are the objectives of studying data structures?

1 Answers  


What is the easiest sorting method to use in data structures?

1 Answers  


Define threaded binary tree.

1 Answers  


Categories