के साथ किसी सरणी के आउटपुट तत्वों को मैंने सरणी को बनाने और पॉप्युलेट करने के लिए नीचे दिए गए कोड का उपयोग किया है, हालांकि, जब सरणी मुद्रित करने की बात आती है तो मुझे Arrays.toString()
फ़ंक्शन का उपयोग करते समय परिणाम प्राप्त नहीं होता है।Arrays.toString()
बजाय मुद्रण
newArray: [2, 4, 6]
newArray: [8, 10, 12]
etc..
यह प्रिंट
newArray: [[[email protected], [[email protected], [[email protected], [[email protected]]
newArray: [[[email protected], [[email protected], [[email protected], [[email protected]]
etc..
कोड:
public static void main(String[] args) {
int[][] newArray = new int[4][3];
int number = 2;
for (int rowCounter = 0; rowCounter < newArray.length; rowCounter++) {
for (int colCounter = 0; colCounter < newArray[rowCounter].length; colCounter++) {
newArray[rowCounter][colCounter] = number;
number += 2;
}
System.out.println("newArray: " + Arrays.toString(newArray));
}
}
इस के साथ किसी भी मदद की बहुत सराहना की जाएगी।
यहाँ परिणाम सरणी नहीं वास्तविक मान आप चाहते हैं –