Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


shivali
Java Array
1 Answer(s)      5 years and 5 months ago
Posted in : Java Beginners



Advertisement
View Answers

April 24, 2009 at 6:15 PM


Hi Friend,

Please try the following code. This will solve your problem.

class SwapDiagonalArray{
public static void main(String[] args){
int TwoDarray[][]=new int[][]{
{1,2,3},
{4,5,6},
{7,8,9}
};
for(int i=0; i<3;i++){
for(int j=0; j<3;j++){
System.out.print(" "+ TwoDarray[i][j]);
}
System.out.println("");
}

for(int i=0; i<3/2;i++){
for(int j=0; j<3/2;j++){
if(i!=j){
TwoDarray[i][j] = TwoDarray[i][j]+TwoDarray[j][i];
TwoDarray[j][i] = TwoDarray[i][j]-TwoDarray[j][i];
TwoDarray[i][j] = TwoDarray[i][j]-TwoDarray[j][i];
}
}
}
for(int i=0; i<3;i++){
for(int j=0; j<3;j++){
System.out.print(" "+ TwoDarray[i][j]);
}
System.out.println("");
}
}
}

Thanks
RoseIndia Team


Related Tutorials/Questions & Answers:
Java array
Java array   How can one prove that the array is not null but empty
Java array
Java array  Java program to find first two maximum numbers in an array,using single loop without sorting array
Advertisements
Java Array
Java Array   a) Write an array program that perform the following: i) Declares a String array initialized with the following strings: √Ę‚?¨Ň...?¨¬?. ii) Write a loop that displays the contents of each element in the array
java array
java array  q4.array Write a program that accepts two arrays, an array of fruit names and an array of price of fruits, and a fruit name and returns the price of the fruit. (Assume that a price in the second array corresponds
java array
java array  write a java method that takes an array of float values...)){ System.out.println("There are duplicate elements."); Float array...++){ array[i]=new Float(arr[i]); } Set<Float>
java array
java array Two cells is a matrix will be called connected if they are adjacent...], a[3,2], a[3,3] } elements with weight 6 Problem: Implement Java code which takes 2 dimensional integer array as input and prints out heaviest island
Array in Java
Array in Java  public class tn { public class State{ String s_name; int p1; int p2; } public void f(){ State[] s = new State[10]; int [] i = new int[10]; i[0] = 1
jagged array in java
jagged array in java   jagged array in java with example
Java Array
In this section, you will learn about array in Java
char array java
char array java  char array programmes in java All capital letters should be replaced with the next letter
sorting array in java
sorting array in java  How to sort array in Java or JavaScript?   JavaScript Sorting array tutorial   Java Sort array of strings...[] args) { String array[]=new String[5]; Scanner input = new Scanner
Array - Java Beginners
Array  how to declare array of hindi characters in java
java array problem
java array problem  suppose i have an array a[] at a[0] i have value 5,7 the thing is that i want to assign the value of array a[0]=5,7 to two variable let it be j,k that is j=5 and k=7 plz help regards
Java Array - Java Beginners
Java Array  Can someone help me to convert this to java? I have an array called Projects{"School", "House", "Bar"} I want all the possible combinations but only once each pair, for example ["House", "Bar"] is the SAME
Java Array Types
Java Array Types  Hi, Can Some one guide me how many types of Java Array uses in developing an application. I need the online tutorial to learn syntax or code of the various types of Java arrays. Thanks
Java Array - Java Beginners
Java Array  Q4-Write a program to exchange the nondiognal elements of a two dimensional array A of size NxN without using any other array ie. each a[i][j]with a[j][i] where i is not equal j?   Hi Friend, Please try
array in javascript - Java Beginners
://www.roseindia.net/java/javascript-array/index.shtml Hope...array in javascript  how to initialize array in javascript and can we increase the size of array later on? is Array class in javascript ? also
array manipulation - Java Beginners
array manipulation  We'll say that a value is "everywhere" in an array if for every pair of adjacent elements in the array, at least one of the pair is that value. Return true if the given value is everywhere in the array
Array in Java
. Different types of array used in Java are One-dimensional, Two-dimensional and multi... of an Array Initialization of an Array Arrays in Java for different data... above arrays in different way, like: int i[]; Construction of an array in Java
Java array - Java Beginners
Java array  Q 1- write a program that counts the frequency... to convert a binary no to integer with out using in built functions? Q 3- Write a program tofind sum of all non dioganal elements of a two dimensional NxN array
java program based on array
java program based on array  write a program to create an array of 10 integers in main.accept values from the user in that array .now again ask the use another nomber and pass the array and the no. entered to function called
Array in Java - Java Beginners
Array in Java  Please help me with the following question. Thank you. Write a program that reads numbers from the keyboard into an array of type int[]. You may assume that there will be 50 or fewer entries in the array. Your
Java Array - Java Beginners
Java Array  Q1-Write a program to exchange non diagonal elements of two dimensinal NXN Array without using temporary array  Hi Friend, Please try the following code to solve your problem. Here is the code: class
array variable in a java program
array variable in a java program  How do i write a program that will prompt the user for a list of 5 prices, that cosist of the sum of all the prices, the average of the prices, and all prices that are higher than the calculated
array in java - Java Interview Questions
array in java  array is a object in java. is it true, if true then what is its class name? or- array object is of which class?  Hi Friend, Please visit the following link: http://www.roseindia.net/java
ARRAY SIZE. - Java Beginners
ARRAY SIZE.  Thanks, well that i know that we can use ArrayList... the elements in array A. Then doubled array A by multiplying it by 2 and then storing it in array B. But gives me error. import java.io.*; import
array sort - Java Beginners
array sort  hi all, can anybody tell me how to sort an array... array[], int len){ for (int i = 1; i < len; i++){ int j = i; int tmp = array[i]; while ((j > 0) && (array[j-1] > tmp
Question in Array Implementation (java) ??!
Question in Array Implementation (java) ??!  Good Morning EveryOne I have Q in Java - and if any One have the Answers please tall me ??!! Question... stores list of ‚??PhoneEntry‚?? objects. Use an array of size (MAXSIZE = 1000
java array - Java Beginners
java array  1.) Consider the method headings: void funcOne(int[] alpha, int size) int funcSum(int x,int y) void funcTwo(int[] alpha, int[] beta...]; int num; Write Java statements that do the following: a. Call
Array in java
Array in java In following example we will discuss about Array in Java. Array... in memory at fixed size. We can use multiple type array. It can be used in Java, C..., Boolean, String object. We can store only primitive data in array. We have
array - Java Beginners
array:5 what is the length of 2nd array:4 enter a number for 1st array: 4 enter a number for 1st array: 6 enter a number for 1st array: 2 enter a number for 1st array: 1 enter a number for 1st array: 7
How to fill double array in java
How to fill double array in java  how to fill double array in java
Simplest way to print an array in Java
Simplest way to print an array in Java  Simplest way to print an array in Java
array - Java Beginners
array  Accept a two dimensional array from the user check if this array is symetric display a message yes,if it is symetric otherwise display it ,is not symetric
array - Java Beginners
*; and no function,,, what is the length of 1st array:5 what is the length of 2nd array:4 enter a number for 1st array: 4 enter a number for 1st array: 6 enter a number for 1st array: 2 enter a number for 1st array: 1 enter a number
about array in java
about array in java  speed of a vehicle is measured using the total time and the distance by using the equation given bellow speed(km/hour)=distance... Vehicle 02 = 5 hours Write a JAVA class to represent the Vehicle. The program should
Array sorting - Java Beginners
Array sorting   Hello All. I need to sort one array based on the arrangement of another array. I fetch two arrays from somewhere... need to sort the "name" array alphabetically. I can do that easily using
Java array in currency converter
Java array in currency converter  Hi all, My sister is trying to teach me java. She's in school for programming and I'm not but I am just trying to learn alongside her. I am quite lost with this multidimensional array. I do
array - Java Beginners
array  how to make a java program that will use an array to determine the number of male and female user??plz help me..:(  Hi Friend, We have used Array List to determine the number of males and females. Here
array password - Java Beginners
array password  i had create a GUI of encryption program that used the array password. my question is can we do the password change program? i mean we change the older password with the new password
Averaging an Array - Java Beginners
the average of an array with the following headers. However, prompt user to enter 10 int and 10 doubles. a) public static int average(int[] array) b) public static double average(double[] array)   Hi Friend, Try the following code
ARRAY - Java Beginners
ARRAY  How To Find Out Unique Elements Of Given Array...) { int array[]={1,2,1,1,3,4,4,3,6,8,0,6,0,3}; int num; int count; for(int i = 0... = 0; j < array.length; j++){ if(j >= i){ if(array[i
Java Array Declaration
Java Array Declaration       As we declare a variable in Java, An Array variable is declared the same way. Array variable has a type and a valid Java identifier i.e. the array's
Java Array declaration
Java Array declaration In this section you will learn how to declare array in java. As we know an array is collection of single type or similar data type. When an array is created its length is determined. An array can hold fixed
Array in JOptionPane - Java Beginners
Array in JOptionPane  Hello, I'm having trouble with printing an array in a JOptionPane. I am supposed to make a 2 dimensional int array called BlasTable. I'm supposed to use a method to print the array in a JOptionPane
Java Programming using array
Java Programming using array  I'm creating a programming using array... Program: import java.io.*; public class Array { public static void main(String args...','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z'}; char ch
array 1 - Java Beginners
array 1  WAP to input values in 2 arrays and merge them to array M...; for (int[] array : arr) { arrSize += array.length; } int[] result = new int[arrSize]; int j = 0; for (int[] array : arr
array - Java Beginners
array  how to determine both the diagonals of a 2-d array? How... the size of 2D array :"); int i=input.nextInt(); int d[][]=new int[i][i]; int j,k; System.out.println("Enter the values of 2D array of "+i+" * "+i
array example - Java Beginners
array example  hi!!!!! can you help me with this question... dependents to Employee that is an array of Dependent objects, and instantiate a five-element array * while this isn't the best practice, there isn't a much better
Array - Java Beginners
using one-dimensional array that accept five input values from the keyboard...(System.in)); int array[] = {2, 5, -2, 6, -3, 8, 10, -7, -9, 4,15}; Arrays.sort(array); int index = Arrays.binarySearch(array, 2
Advertisements
 

 

 

DMCA.com