Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Square Elements of Two Dimensional Array 
 

This is a simple java program for implementing the two dimensional array program and its square. This session provide you the best explanation with mathematical operation.

 

Square Elements of Two Dimensional Array 

                         

This is a simple java program for implementing the two dimensional array program and its square. This session provide you the best explanation with mathematical operation. 

Description of progarm:

We are going to display the square of two matrix. Firstly, we have to define a class "SquareMatrix".  Then we take an integer type array that contains integer type values. After this, we use two 'for' loop that denotes rows and columns of a matrix. After getting both the matrix with us we need to square both matrix. When we go to square this array then we use "square[i][j] =square[i][j] * square[i][j]". So, the output will be displayed on the screen command prompt by using the println() method.

Here is the code of this program

public class SquareMatrix {
    public static void main(String[] args) {
    int square[][]{{1,3,5},{2,4,6}};
    System.out.println("Your Original Matrix: ");
    for(int i = 0; i < 2; i++){
      for(int j = 0; j < 3; j++){
        System.out.print(square[i][j" ");
      }
      System.out.println();
    }
    for(int i = 0; i <= 1; i++) {
      for(int j = 0; j <= 2; j++) {
        square[i][j= square[i][j* square[i][j];
      
        }
    System.out.println("Matrix after changes: ");
    for(int i = 0; i < 2; i++){
      for(int j = 0; j < 3; j++){
        System.out.print(square[i][j" ");
      }
      System.out.println();
    }
    }
}

 Download this Example    

                         

» View all related tutorials
Related Tags: c file class orm constructor object path struct const value name return instance paths create if send match to bot

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

2 comments so far (
post your own) View All Comments Latest 10 Comments:

can you pls give me the code of the magic square that the user will only enter a number
thank you

Posted by maria duropan on Thursday, 12.4.08 @ 01:58am | #82364

can you pls give me the code of the magic square that the user will only enter a number
thank you

Posted by maria duropan on Thursday, 12.4.08 @ 01:56am | #82363

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.