PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy) (एरे एरर्स: बाउंड्स एक्सेप्शन और System.arraycopy विधि) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।
Overview: Java enforces strict runtime array bounds checking, throwing ArrayIndexOutOfBoundsException whenever an index falls outside 0 to length - 1. For high-speed bulk transfers between arrays, System.arraycopy() delegates directly to optimized native memory-copy routines.
अध्याय सार: जावा कठोर रनटाइम एरे बाउंड्स चेकिंग लागू करता है और इंडेक्स के 0 से length - 1 के बाहर होने पर ArrayIndexOutOfBoundsException फेंकता है। एरे के बीच तीव्र बल्क डेटा कॉपी के लिए System.arraycopy() सीधे ऑप्टिमाइज़्ड नेटिव मेमोरी-कॉपी रूटीन का उपयोग करता है।
ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy): Detailed Notes & Architecture (एरे एरर्स: बाउंड्स एक्सेप्शन और System.arraycopy विधि)
1. ArrayIndexOutOfBoundsException and JVM Bounds Checking (ArrayIndexOutOfBoundsException और JVM बाउंड्स चेकिंग)
[EN] Unlike C or C++ where out-of-range array reads cause silent buffer overflows or memory corruption, the JVM verifies every array access at runtime. If an index is negative (< 0) or greater than or equal to array.length, the JVM throws java.lang.ArrayIndexOutOfBoundsException. This class is an unchecked RuntimeException extending IndexOutOfBoundsException, so methods do not have to declare it in a throws clause. Common triggers include off-by-one loop conditions like i <= arr.length or accessing index 0 on an empty zero-length array.
[HI] C या C++ के विपरीत जहाँ सीमा से बाहर एक्सेस करने पर साइलेंट बफर ओवरफ़्लो होता है, JVM रनटाइम पर प्रत्येक एरे एक्सेस की जांच करता है। यदि इंडेक्स ऋणात्मक (< 0) या array.length के बराबर अथवा अधिक हो, तो JVM java.lang.ArrayIndexOutOfBoundsException फेंकता है। यह IndexOutOfBoundsException से इनहेरिट होने वाला अनचेक्ड RuntimeException है, इसलिए इसे throws क्लॉज़ में लिखना अनिवार्य नहीं है। इसके सामान्य कारणों में i <= arr.length जैसी ऑफ़-बाय-वन त्रुटि या 0-लंबाई वाले एरे में इंडेक्स 0 पढ़ना शामिल है।
2. Related Array Exceptions: ArrayStoreException & NegativeArraySizeException (संबंधित एरे एक्सेप्शंस: ArrayStoreException और NegativeArraySizeException)
[EN] Besides bounds errors, Java arrays can trigger NegativeArraySizeException when instantiated with a negative length and NullPointerException when indexing a null array reference. Because Java arrays are covariant (String[] is a subtype of Object[]), storing an incompatible object such as an Integer into an Object[] reference backed by a String[] compiles cleanly. However, at runtime the JVM performs an element type check and throws ArrayStoreException to preserve heap type safety. Catching IndexOutOfBoundsException handles both ArrayIndexOutOfBoundsException and StringIndexOutOfBoundsException simultaneously.
[HI] बाउंड्स त्रुटि के अलावा ऋणात्मक साइज पर NegativeArraySizeException और null एरे रेफरेंस पर NullPointerException आता है। जावा एरे कोवेरिएंट (covariant) होते हैं (String[], Object[] का सबटाइप है), इसलिए String[] को होल्ड करने वाले Object[] में Integer डालने का कोड कंपाइल हो जाता है। परंतु रनटाइम पर JVM तत्व के टाइप की जांच करके टाइप सुरक्षा हेतु ArrayStoreException फेंकता है। IndexOutOfBoundsException को कैच करके ArrayIndexOutOfBoundsException और StringIndexOutOfBoundsException दोनों को संभाला जा सकता है।
3. System.arraycopy() Signature, Parameters, and Behavior (System.arraycopy() का सिग्नेचर, पैरामीटर्स और कार्यप्रणाली)
[EN] Declared as public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length) in java.lang.System, it copies a subsequence of elements from source to destination. Being a native method implemented in C/assembly inside the JVM, it typically compiles down to vectorized CPU block-copy instructions much faster than manual Java for loops. If src and dest refer to the exact same array with overlapping index ranges, System.arraycopy guarantees safe copying as if copied through a temporary array first. It throws ArrayStoreException if component types are incompatible, IndexOutOfBoundsException (in Java 8+ specifically ArrayIndexOutOfBoundsException) on invalid bounds, or NullPointerException if either array is null.
[HI] java.lang.System में public static native void arraycopy(Object src, int srcPos, Object dest, int destPos, int length) मेथड एक एरे से दूसरे एरे में तत्वों का भाग कॉपी करता है। JVM के भीतर C/असेंबली में निर्मित native मेथड होने के कारण यह मैनुअल for लूप की तुलना में बहुत तेज़ ब्लॉक-मेमोरी कॉपी करता है। यदि src और dest एक ही एरे हों और रेंज ओवरलैप कर रही हों, तब भी System.arraycopy डेटा खराब किए बिना सुरक्षित कॉपी की गारंटी देता है। असंगत टाइप पर ArrayStoreException, गलत सीमाओं पर IndexOutOfBoundsException और null एरे पर NullPointerException फेंका जाता है।
4. Comparing System.arraycopy, Arrays.copyOf, and clone() (System.arraycopy, Arrays.copyOf और clone() की तुलना)
[EN] System.arraycopy requires the caller to pre-allocate the destination array before copying, offering fine control over source and target offsets. In contrast, java.util.Arrays.copyOf(original, newLength) and Arrays.copyOfRange(original, from, to) allocate and return a brand-new array internally using System.arraycopy. If newLength exceeds original.length, Arrays.copyOf pads trailing slots with type default values (0, false, or null). Crucially, arraycopy, Arrays.copyOf, and clone() all perform shallow copies for object arrays, copying references rather than cloning individual target objects.
[HI] System.arraycopy में कॉपी करने से पहले गंतव्य एरे को आवंटित करना आवश्यक होता है और यह सोर्स व डेस्टिनेशन ऑफ़सेट पर पूरा नियंत्रण देता है। इसके विपरीत java.util.Arrays.copyOf(original, newLength) और Arrays.copyOfRange() आंतरिक रूप से System.arraycopy का उपयोग करके नया एरे बनाकर लौटाते हैं। यदि newLength मूल लंबाई से अधिक हो, तो Arrays.copyOf अतिरिक्त स्लॉट्स में डिफ़ॉल्ट मान (0, false या null) भर देता है। महत्वपूर्ण बात यह है कि arraycopy, Arrays.copyOf और clone() सभी ऑब्जेक्ट एरे की केवल शैलो कॉपी (रेफरेंस कॉपी) करते हैं।
Syntax, Formula & Technical Example (ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy))
int[] src = {10, 20, 30, 40, 50};
int[] dest = new int[4];
System.arraycopy(src, 1, dest, 1, 3);
// dest becomes {0, 20, 30, 40}
try {
System.out.println(dest[4]);
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Invalid index!");
}
ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy) Quick Reference & Comparison Table
| Method / Exception | Core Behavior | Exam Fact |
|---|---|---|
| ArrayIndexOutOfBoundsException | Index < 0 or >= length at runtime | Unchecked RuntimeException; subclass of IndexOutOfBoundsException |
| ArrayStoreException | Incompatible runtime element assignment | Caused by array covariance e.g. Integer into String[] |
| System.arraycopy(...) | Native fast partial or full block copy | Requires pre-allocated dest; safe on overlapping same-array copy |
| Arrays.copyOf(arr, len) | Creates and returns new resized array | Pads extra slots with defaults; shallow copy for objects |
ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy) Top 20 Bilingual MCQs with Answers
Q1. Which class is the direct superclass of ArrayIndexOutOfBoundsException?
(ArrayIndexOutOfBoundsException की प्रत्यक्ष सुपरक्लास कौन-सी है?)
(A) IndexOutOfBoundsException
(B) ArithmeticException
(C) IllegalArgumentException
(D) IOException
Correct Answer: (A)
[EN] ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException, which extends RuntimeException.
[HI] ArrayIndexOutOfBoundsException सीधे IndexOutOfBoundsException को एक्सटेंड करता है जो RuntimeException का सबक्लास है।
Q2. Is ArrayIndexOutOfBoundsException a checked or an unchecked exception in Java?
(जावा में ArrayIndexOutOfBoundsException किस श्रेणी का एक्सेप्शन है?)
(A) Checked exception requiring throws declaration
(B) Compile-time syntax error
(C) Fatal JVM Error subclass
(D) Unchecked exception (subclass of RuntimeException)
Correct Answer: (D)
[EN] Since it inherits from RuntimeException, the compiler does not force try-catch or throws declarations.
[HI] RuntimeException से इनहेरिट होने के कारण यह अनचेक्ड एक्सेप्शन है और इसे try-catch या throws में लिखना अनिवार्य नहीं है।
Q3. What is the exact parameter order of System.arraycopy?
(System.arraycopy मेथड के पैरामीटर्स का सही क्रम क्या है?)
(A) (src, srcPos, dest, destPos, length)
(B) (src, length, dest, srcPos, destPos)
(C) (dest, destPos, src, srcPos, length)
(D) (src, dest, srcPos, destPos, length)
Correct Answer: (A)
[EN] System.arraycopy takes source array and offset first, destination array and offset next, and element count last.
[HI] System.arraycopy पहले सोर्स एरे व सोर्स ऑफ़सेट, फिर डेस्टिनेशन एरे व डेस्टिनेशन ऑफ़सेट और अंत में लंबाई लेता है।
Q4. Which exception is thrown by Object[] obj = new String[2]; obj[0] = 42; at runtime?
(कोड Object[] obj = new String[2]; obj[0] = 42; चलाने पर रनटाइम पर कौन-सा एक्सेप्शन आएगा?)
(A) Compile-time error
(B) ArrayIndexOutOfBoundsException
(C) ArrayStoreException
(D) ClassCastException
Correct Answer: (C)
[EN] Because arrays are covariant, javac compiles it, and the JVM detects the incompatible Integer stored into String[] at runtime.
[HI] एरे कोवेरिएंट होने से यह कोड कंपाइल हो जाता है, लेकिन रनटाइम पर String[] में Integer रखने पर ArrayStoreException आता है।
Q5. What are the contents of dest after: int[] s = {1,2,3,4}; int[] d = new int[4]; System.arraycopy(s, 1, d, 2, 2);?
(int[] s = {1,2,3,4}; int[] d = new int[4]; System.arraycopy(s, 1, d, 2, 2); के बाद d के तत्व क्या होंगे?)
(A) {1, 2, 0, 0}
(B) {0, 2, 3, 0}
(C) {0, 0, 1, 2}
(D) {0, 0, 2, 3}
Correct Answer: (D)
[EN] Copying 2 elements starting at s[1] (values 2 and 3) into d starting at index 2 leaves d[0] and d[1] as 0.
[HI] s[1] से शुरू करके 2 तत्व (2 और 3) d के इंडेक्स 2 से कॉपी होते हैं, जिससे d = {0, 0, 2, 3} बनता है।
Q6. Why is System.arraycopy declared with the native keyword in java.lang.System?
(java.lang.System में System.arraycopy को native कीवर्ड के साथ क्यों घोषित किया गया है?)
(A) It runs inside a separate OS child process
(B) Its implementation runs in native machine code (C/assembly) for fast block memory transfer
(C) It executes only on mobile Android devices
(D) It bypasses all array bounds and type checks
Correct Answer: (B)
[EN] Native implementation uses hardware-optimized memory copy routines while still validating bounds and types before copying.
[HI] नेटिव इम्प्लीमेंटेशन हार्डवेयर-ऑप्टिमाइज़्ड मेमोरी कॉपी रूटीन का उपयोग करता है और कॉपी से पहले बाउंड्स व टाइप जांच भी करता है।
Q7. What happens when System.arraycopy copies overlapping slices within the same array, such as System.arraycopy(a, 0, a, 1, 3)?
(एक ही एरे में ओवरलैपिंग स्लाइस कॉपी करने पर, जैसे System.arraycopy(a, 0, a, 1, 3), क्या होता है?)
(A) It safely copies elements without overwriting unread source values
(B) Throws OverlappingArrayException
(C) Compilation fails because src and dest match
(D) It corrupts trailing elements by overwriting in place
Correct Answer: (A)
[EN] The JVM specification guarantees same-array overlapping copies behave as if copied through a temporary intermediate buffer.
[HI] JVM स्पेसिफिकेशन गारंटी देता है कि एक ही एरे में ओवरलैपिंग कॉपी अस्थायी बफर की तरह सुरक्षित रूप से काम करती है।
Q8. What happens if System.arraycopy(intArr, 0, doubleArr, 0, 2) is invoked?
(यदि System.arraycopy(intArr, 0, doubleArr, 0, 2) चलाया जाए तो क्या होगा?)
(A) Automatically widens int values to double
(B) Throws ArrayStoreException at runtime
(C) Compile-time type mismatch error
(D) Copies raw binary bits silently
Correct Answer: (B)
[EN] System.arraycopy does not perform primitive widening conversions; primitive component types must match identically.
[HI] System.arraycopy प्रिमिटिव वाइडनिंग कन्वर्ज़न नहीं करता; प्रिमिटिव एरे के कॉम्पोनेंट टाइप बिल्कुल समान होने चाहिए।
Q9. How does Arrays.copyOf(arr, newLength) differ from System.arraycopy()?
(Arrays.copyOf(arr, newLength) की कार्यप्रणाली System.arraycopy() से किस प्रकार भिन्न है?)
(A) Arrays.copyOf works only for String arrays
(B) Arrays.copyOf allocates and returns a new array automatically
(C) Arrays.copyOf performs deep cloning of nested objects
(D) Arrays.copyOf does not check array bounds
Correct Answer: (B)
[EN] Arrays.copyOf internally calls System.arraycopy after creating a new array of the requested length.
[HI] Arrays.copyOf वांछित लंबाई का नया एरे आवंटित करके लौटाता है और आंतरिक रूप से System.arraycopy का उपयोग करता है।
Q10. What happens if you pass a null destination array to System.arraycopy(src, 0, null, 0, 1)?
(System.arraycopy(src, 0, null, 0, 1) कॉल करने पर क्या होता है?)
(A) Does nothing and returns safely
(B) Throws NullPointerException
(C) Allocates a new destination array
(D) Throws IllegalArgumentException
Correct Answer: (B)
[EN] Passing null for either src or dest causes System.arraycopy to throw NullPointerException immediately.
[HI] src या dest में से किसी को भी null पास करने पर System.arraycopy तुरंत NullPointerException फेंकता है।
Q11. Which loop condition is the most frequent cause of ArrayIndexOutOfBoundsException?
(ArrayIndexOutOfBoundsException आने का सबसे सामान्य लूप कारण कौन-सा है?)
(A) for (int x : arr)
(B) for (int i = 0; i <= arr.length; i++)
(C) for (int i = arr.length - 1; i >= 0; i--)
(D) for (int i = 0; i < arr.length; i++)
Correct Answer: (B)
[EN] Using <= instead of < tries to access arr[arr.length] on the final pass, which is one past the last valid index.
[HI] < के स्थान पर <= का उपयोग करने से अंतिम चरण में arr[arr.length] एक्सेस होता है जो वैध सीमा से बाहर है।
Q12. If String[] a = {"A", "B"}; String[] b = Arrays.copyOf(a, 4); what are b[2] and b[3]?
(यदि String[] a = {"A", "B"}; String[] b = Arrays.copyOf(a, 4); हो, तो b[2] और b[3] के मान क्या होंगे?)
(A) "A" and "B"
(B) Throws IndexOutOfBoundsException
(C) null and null
(D) "" and ""
Correct Answer: (C)
[EN] When Arrays.copyOf increases array length, trailing reference slots are padded with null.
[HI] जब Arrays.copyOf लंबाई बढ़ाता है, तो अतिरिक्त रेफरेंस स्लॉट्स में डिफ़ॉल्ट रूप से null भरा जाता है।
Q13. What does System.arraycopy throw if srcPos + length exceeds src.length?
(यदि srcPos + length का मान src.length से अधिक हो जाए तो System.arraycopy कौन-सा एक्सेप्शन फेंकता है?)
(A) BufferOverflowException
(B) NegativeArraySizeException
(C) ArrayStoreException
(D) IndexOutOfBoundsException (ArrayIndexOutOfBoundsException)
Correct Answer: (D)
[EN] Any out-of-bounds offset or length causes an IndexOutOfBoundsException (specifically ArrayIndexOutOfBoundsException) without partial copying.
[HI] किसी भी गलत ऑफ़सेट या लंबाई पर आंशिक कॉपी किए बिना IndexOutOfBoundsException (ArrayIndexOutOfBoundsException) आता है।
Q14. Which of the following is NOT true about System.arraycopy()?
(System.arraycopy() के बारे में निम्न में से कौन-सा कथन सत्य नहीं है?)
(A) It creates deep clones of mutable objects stored inside object arrays
(B) It can copy elements into a specific starting offset in the destination array
(C) It throws ArrayStoreException if src or dest is not an array
(D) It leaves the source array unmodified when copying to a separate destination
Correct Answer: (A)
[EN] For object arrays, System.arraycopy copies object references only (shallow copy); it never clones target objects.
[HI] ऑब्जेक्ट एरे के लिए System.arraycopy केवल ऑब्जेक्ट रेफरेंस की शैलो कॉपी करता है, यह ऑब्जेक्ट्स की डीप क्लोनिंग नहीं करता।
Q15. What happens if length passed to System.arraycopy(src, 0, dest, 0, 0) is 0?
(यदि System.arraycopy(src, 0, dest, 0, 0) में लंबाई 0 दी जाए और एरे वैध हों तो क्या होगा?)
(A) Throws ArrayIndexOutOfBoundsException
(B) Copies zero elements and completes without error
(C) Clears the destination array to defaults
(D) Throws IllegalArgumentException
Correct Answer: (B)
[EN] Copying 0 elements with valid non-null arrays and valid indices (0 <= pos <= length) is a legal no-op.
[HI] वैध गैर-null एरे और वैध इंडेक्स के साथ लंबाई 0 देना पूरी तरह वैध है और यह बिना त्रुटि कोई तत्व कॉपी किए बिना समाप्त होता है।
Q16. Why can you safely pass new int[0] to Arrays.copyOf(new int[0], 3)?
(Arrays.copyOf(new int[0], 3) बिना त्रुटि के कैसे काम करता है?)
(A) Arrays.copyOf converts 0-length arrays to null
(B) It modifies the original array in place
(C) It throws an exception only when newLength is 0
(D) It creates a new int[3] initialized to {0, 0, 0} copying 0 elements from the source
Correct Answer: (D)
[EN] Arrays.copyOf copies min(original.length, newLength) elements (0 here) and allocates the remaining slots with 0.
[HI] Arrays.copyOf सोर्स से min(0, 3) अर्थात 0 तत्व कॉपी करता है और शेष स्लॉट्स में 0 के साथ नया int[3] बना देता है।
Q17. Within ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy), which method / exception directly maps to: "Index < 0 or >= length at runtime"?
(ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy) में कौन सा Method / Exception सीधे "Index < 0 or >= length at runtime" से संबंधित है?)
(A) Arrays.copyOf(arr, len)
(B) System.arraycopy(...)
(C) ArrayStoreException
(D) ArrayIndexOutOfBoundsException
Correct Answer: (D)
[EN] In ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy), 'ArrayIndexOutOfBoundsException' handles 'Index < 0 or >= length at runtime' (Unchecked RuntimeException; subclass of IndexOutOfBoundsException).
[HI] ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy) में 'ArrayIndexOutOfBoundsException' का कार्य/विवरण 'Index < 0 or >= length at runtime' (Unchecked RuntimeException; subclass of IndexOutOfBoundsException) है।
Q18. Which option accurately describes 'ArrayStoreException' in ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy)?
(ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy) के संदर्भ में 'ArrayStoreException' की सही विशेषता कौन सी है?)
(A) Index < 0 or >= length at runtime
(B) Creates and returns new resized array
(C) Native fast partial or full block copy
(D) Incompatible runtime element assignment
Correct Answer: (D)
[EN] 'ArrayStoreException' provides 'Incompatible runtime element assignment' — key point: Caused by array covariance e.g. Integer into String[].
[HI] 'ArrayStoreException' का मुख्य विवरण 'Incompatible runtime element assignment' है (Caused by array covariance e.g. Integer into String[])।
Q19. In ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy), identify the correct parameter for the specification: "Native fast partial or full block copy".
(ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy) में "Native fast partial or full block copy" विवरण किस विकल्प के लिए सही है?)
(A) System.arraycopy(...)
(B) ArrayIndexOutOfBoundsException
(C) ArrayStoreException
(D) Arrays.copyOf(arr, len)
Correct Answer: (A)
[EN] 'System.arraycopy(...)' corresponds to 'Native fast partial or full block copy' (Requires pre-allocated dest; safe on overlapping same-array copy).
[HI] 'System.arraycopy(...)' का संबंध 'Native fast partial or full block copy' (Requires pre-allocated dest; safe on overlapping same-array copy) से है।
Q20. Considering ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy), what key behavior defines 'Arrays.copyOf(arr, len)'?
(ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy) में 'Arrays.copyOf(arr, len)' की मुख्य भूमिका या मान क्या है?)
(A) Incompatible runtime element assignment
(B) Native fast partial or full block copy
(C) Index < 0 or >= length at runtime
(D) Creates and returns new resized array
Correct Answer: (D)
[EN] 'Arrays.copyOf(arr, len)' represents 'Creates and returns new resized array' (Pads extra slots with defaults; shallow copy for objects).
[HI] 'Arrays.copyOf(arr, len)' का अर्थ/मान 'Creates and returns new resized array' है (Pads extra slots with defaults; shallow copy for objects)।
ArrayIndexOutOfBoundsException and Array Copying (System.arraycopy) — Exam FAQs
Q1: Does System.arraycopy modify the destination array if an ArrayStoreException occurs midway?
यदि बीच में ArrayStoreException आए तो क्या System.arraycopy डेस्टिनेशन एरे को आंशिक रूप से बदल देता है?
[EN] For Object[] to compatible supertype/subtype copies, elements copied before the incompatible element MAY remain modified in dest; bounds checks happen beforehand so IndexOutOfBoundsException never partially modifies dest.
[HI] ऑब्जेक्ट एरे में असंगत तत्व आने से पहले कॉपी हुए तत्व dest में बदल सकते हैं; हालांकि बाउंड्स जांच कॉपी से पहले होती है इसलिए IndexOutOfBoundsException पर dest आंशिक रूप से नहीं बदलता।
Q2: Why is System.arraycopy preferred inside ArrayList internals?
ArrayList के आंतरिक कोड में System.arraycopy को प्राथमिकता क्यों दी जाती है?
[EN] When ArrayList grows capacity or removes/inserts elements in the middle, System.arraycopy shifts contiguous backing array slots at native C/assembly speed.
[HI] जब ArrayList अपनी क्षमता बढ़ाता है या बीच से तत्व हटाता/जोड़ता है, तो System.arraycopy नेटिव गति से बैकिंग एरे के स्लॉट्स को शिफ्ट करता है।
Q3: How do you copy a slice of an array without manually allocating the target first?
पहले से लक्ष्य एरे बनाए बिना किसी एरे का हिस्सा (slice) कैसे कॉपी करें?
[EN] Use Arrays.copyOfRange(original, fromInclusive, toExclusive), which allocates and returns the sliced sub-array in one call.
[HI] Arrays.copyOfRange(original, fromInclusive, toExclusive) का उपयोग करें, जो एक ही कॉल में नया सब-एरे आवंटित करके लौटाता है।
Post a Comment
Post a Comment