Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6653743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:18:26+00:00 2026-05-26T01:18:26+00:00

Wen I have this code: import java.util.Scanner; import java.util.Arrays; public class Ex02 { /**

  • 0

Wen I have this code:

    import java.util.Scanner;
    import java.util.Arrays;
    public class Ex02 {

        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            int [] matrixSize = new int [4];
            System.out.println("Insert the values matrix (matrixA_lines,MatrixA_Rows,matrixB_lines,MatrixB_Rows");
            matrixSize = matrixFill(4);
            System.out.println(Arrays.toString(matrixSize));
        }

        public static int[] matrixFill(int sizeOne){
            int i;
            Scanner sc = new Scanner(System.in);

            int [] matrixTemp = new int [sizeOne];
            for (i = 0; i<sizeOne; i++){
                matrixTemp[i] = sc.nextInt();
            }

            return matrixTemp;
        }
    }

It all works as expected. An unidimensional array is created, filled with 1,2,3,4 and them the array is print. The problem is that i want to use an bidimentsional array. I’ve modified the code and it gives error.
Here is the modified code:

import java.util.Scanner;
import java.util.Arrays;
public class Ex02 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int [][] matrixSize = new int [1][4];
        System.out.println("Insert the values matrix (matrixA_lines,MatrixA_Rows,matrixB_lines,MatrixB_Rows");
        matrixSize[][] = matrixFill(1,4);
        System.out.println(Arrays.deepToString(matrixSize));
    }

    public static int[][] matrixFill(int sizeOne, int sizeTwo){
        int i;
        Scanner sc = new Scanner(System.in);

        int [][] matrixTemp = new int [sizeOne][sizeTwo];
        for (i = 0; i<sizeOne; i++){
            matrixTemp[0][i] = sc.nextInt();
        }

        return matrixTemp[sizeOne][sizeTwo];
    }
}

On line 21 (matrixSize[][] = matrixFill(1,4);) the error is:

cannot find symbol
symbol:   class matrixSize
location: class Ex02.Ex02

not a statement

';' expected

And on line 34(return matrixTemp[sizeOne][sizeTwo];) the error is:

incompatible types
required: int[][]
found:    int

Can someone tell me what I’m doing wrong? Just started to learn Java.

Regards,

favolas

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:18:27+00:00Added an answer on May 26, 2026 at 1:18 am

    Remove the [][] from matrixSize, and from your return value.

    matrixSize = matrixFill(1,4);
    

    And

    return matrixTemp;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two models like this: class Topic < ActiveRecord::Base has_many :articles end class
Ok before i make spaghetti of this code i thought id ask around here.
I have an emergency here. This homework is due tomorrow for my CP 1
In my rails app I have 2 models: post and post_translations. class PostTranslation <
I am a wen developer, I have now started a new project for the
I have a project which has fusion widgets embedded in it. wen i run
I made a java application.and bundled all classes in jar file..wen i run the
The Code below on execution in android throws IOException but not wen executed as
i have been trying to uplaod an application to apple store for 2 days
As in wen you run any output in a frame, every time you run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.