Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: java computer science array access issues

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default java computer science array access issues

    I exactly what my problem is but I don't know how to fix it. I must access the arrays/matrix then have them dislplay on the screen in a certain order. I have attach a word doc for the order need. My main issue is accessing the array I know there is an issue with the way I access the arrays and I don't know how to sort and take out the data in the array. don't worry the doc is clean and thank you for your time!

    // TextLab07st.java
    // This is the student, starting file of the TextLab07 assignment.

    import java.util.Random;

    public class TextLab07st
    {
    public static void main(String args[])
    {
    System.out.println("TextLab07v100\n\n");
    Matrix m1 = new Matrix(3,4,1234);
    Matrix m2 = new Matrix(3,4,1234);
    Matrix m3 = new Matrix(3,4,4321);
    System.out.println("Matrix m1\n");
    System.out.println(m1+"\n\n");
    System.out.println("Matrix m2\n");
    System.out.println(m2+"\n\n");
    System.out.println("Matrix m3\n");
    System.out.println(m3+"\n\n");
    if (m1.equals(m2))
    System.out.println("m1 is equal to m2\n");
    else
    System.out.println("m1 is not equals to m2\n");
    if (m1.equals(m3))
    System.out.println("m1 is equal to m3\n");
    else
    System.out.println("m1 is not equals to m3\n");
    }
    }

    class Matrix
    {
    private int rows;
    private int cols;
    private int mat[][];

    public Matrix(int rows, int cols, int seed)
    {
    this.rows = rows;
    this.cols = cols;
    mat = new int[rows][cols];
    Random rnd = new Random(seed);
    for (int r = 0; r < rows; r ++)
    for (int c = 0; c < cols; c++)
    {
    int randomInt = rnd.nextInt(90) + 10;
    mat[r][c] = randomInt;

    }
    }
    public String ToString()
    {
    String OrenthalJames213 = "";

    for (int r = 0; r < rows; r++);
    {

    }

    for (int qw = 0; qw < cols; qw++)
    {

    OrenthalJames213 = mat[r][qw];
    }


    return OrenthalJames213;






    }
    }
    Attached Files Attached Files


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,973
    Thanks
    51
    Thanked 2,269 Times in 2,241 Posts

    Default Re: java computer science array access issues

    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.

    Please copy and paste here the text of any doc needed. No links.

    My main issue is accessing the array
    Please explain what the issue is.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Can someone help me with my Computer Science homework :)
    By surfelijo in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 1st, 2013, 08:18 PM
  2. AP computer science questions
    By svo in forum Java Theory & Questions
    Replies: 1
    Last Post: April 7th, 2012, 02:24 PM
  3. AP computer science questions
    By svo in forum Java Theory & Questions
    Replies: 1
    Last Post: April 6th, 2012, 11:32 PM
  4. need help in AP Computer Science!
    By eechord in forum Member Introductions
    Replies: 3
    Last Post: October 7th, 2011, 09:57 AM
  5. computer science help
    By hairyjewbear in forum Algorithms & Recursion
    Replies: 6
    Last Post: November 4th, 2010, 04:05 PM

Tags for this Thread