Click here to Skip to main content
15,914,071 members
Home / Discussions / Java
   

Java

 
GeneralRe: code coverage Pin
Richard MacCutchan18-Oct-09 22:18
mveRichard MacCutchan18-Oct-09 22:18 
GeneralRe: code coverage Pin
Shakirin Amin18-Oct-09 7:34
Shakirin Amin18-Oct-09 7:34 
QuestionRe: minesweeper Pin
Kristine Casin15-Oct-09 1:30
Kristine Casin15-Oct-09 1:30 
AnswerRe: minesweeper Pin
Richard MacCutchan15-Oct-09 2:15
mveRichard MacCutchan15-Oct-09 2:15 
AnswerRe: minesweeper Pin
427748016-Oct-09 6:23
427748016-Oct-09 6:23 
GeneralRe: minesweeper Pin
Kristine Casin21-Oct-09 1:33
Kristine Casin21-Oct-09 1:33 
GeneralRe: minesweeper Pin
Kristine Casin27-Oct-09 1:30
Kristine Casin27-Oct-09 1:30 
QuestionAdding / Multiplying two matrices Pin
nt_virus14-Oct-09 22:52
nt_virus14-Oct-09 22:52 
Hello. I did this..
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication6;
import java.io.*;
/**
 *
 * @author Sachin
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException 
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try{
    System.out.println("Enter number of rows");
    int m = Integer.parseInt(br.readLine());
    System.out.println("Enter number of columns");
    int n = Integer.parseInt(br.readLine());
    int[][] first = new int[m][n];
    int[][] second = new int[m][n];
    int[][] sum = new int[m][n];
    System.out.println("Enter Value of first matrix");
    {
        for (int i=0;i<m;m++)
        {
        //    System.out.println("Row no. " + (i+1));
            for (int j=0; j<n;j++)
            {
       //        System.out.println("Enter value for column no. " + (j+1));
               first[m][n] = Integer.parseInt(br.readLine());
               
            }
        }
    }
    System.out.println("Enter value of second matrix");
    {
        for (int i=0;i<m;m++)
        {
            System.out.println("Row no. " + (i+1));
            for (int j=0;j<n;j++)
            {
                System.out.println("Enter value for column no. " + (j+1));
                second[m][n] = Integer.parseInt(br.readLine());
            }
        }
        }
    System.out.println("Sum of two matrices are:");
    {
        for (int i=0;i<m;i++)
        {
            for (int j = 0; j<n;j++)
            {
                sum[m][n] = first[m][n] + second[m][n];
            }
        }
        System.out.println(sum[m][n]);
    }
    }
    catch (IOException e)
    {
       System.out.println(e);
    }
    }
}


Here in bold text..
first[m][n] = Integer.parseInt(br.readLine());
throws ArrayIndexOutOfBoundexception ....

When I replace first[m][n] with first[i][j] .. it taking value ..
how to rectify this error any suggestion..
AnswerRe: Adding / Multiplying two matrices Pin
Richard MacCutchan15-Oct-09 0:19
mveRichard MacCutchan15-Oct-09 0:19 
GeneralRe: Adding / Multiplying two matrices Pin
nt_virus15-Oct-09 0:22
nt_virus15-Oct-09 0:22 
GeneralRe: Adding / Multiplying two matrices Pin
Richard MacCutchan15-Oct-09 2:01
mveRichard MacCutchan15-Oct-09 2:01 
GeneralRe: Adding / Multiplying two matrices Pin
nt_virus15-Oct-09 2:36
nt_virus15-Oct-09 2:36 
GeneralRe: Adding / Multiplying two matrices Pin
Richard MacCutchan15-Oct-09 2:47
mveRichard MacCutchan15-Oct-09 2:47 
GeneralRe: Adding / Multiplying two matrices Pin
nt_virus15-Oct-09 2:49
nt_virus15-Oct-09 2:49 
GeneralRe: Adding / Multiplying two matrices Pin
nt_virus15-Oct-09 2:48
nt_virus15-Oct-09 2:48 
GeneralRe: Adding / Multiplying two matrices Pin
Richard MacCutchan15-Oct-09 4:32
mveRichard MacCutchan15-Oct-09 4:32 
GeneralRe: Adding / Multiplying two matrices Pin
nt_virus15-Oct-09 4:57
nt_virus15-Oct-09 4:57 
GeneralRe: Adding / Multiplying two matrices Pin
Richard MacCutchan15-Oct-09 4:59
mveRichard MacCutchan15-Oct-09 4:59 
GeneralRe: Adding / Multiplying two matrices Pin
nt_virus15-Oct-09 5:00
nt_virus15-Oct-09 5:00 
GeneralRe: Adding / Multiplying two matrices Pin
Richard MacCutchan15-Oct-09 6:35
mveRichard MacCutchan15-Oct-09 6:35 
GeneralRe: Adding / Multiplying two matrices Pin
nt_virus15-Oct-09 7:42
nt_virus15-Oct-09 7:42 
GeneralRe: Adding / Multiplying two matrices Pin
Richard MacCutchan15-Oct-09 7:46
mveRichard MacCutchan15-Oct-09 7:46 
GeneralRe: Adding / Multiplying two matrices Pin
nt_virus15-Oct-09 7:50
nt_virus15-Oct-09 7:50 
GeneralRe: Adding / Multiplying two matrices Pin
Richard MacCutchan15-Oct-09 9:21
mveRichard MacCutchan15-Oct-09 9:21 
QuestionHow to load a picture in JFrame Pin
akosidandan14-Oct-09 17:02
akosidandan14-Oct-09 17:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.