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

import java.swing.*;
import java.math.*;
public class KonvertoMatricenNeVektor {

public static void main(String[] args)
{int a =new Integer (JOptionPane.showInputDialog("Jepni numrin e rreshtave")).intValue();
int b= new Integer(JOptionPane.showInputDialog("Jepni numrin e shtyllave")).intValue();
int matrica [][]=new int [a][b];
for(int i=0; i<b; i++)
{for(int j=0; j<a; j++)
matrica[i][j]=(int) ((int) Math.random()*10);
vektor(matrica);}}
public static void vektor(int[][]m)
{int rr=0;
int sh=0;
for(int i=0;i<m.length;i++)
{ rr+=1;
for(int j=0;j<m[i].length;j++)
sh+=1;}
int vektor[]=new int[rr*sh];
int k=0;
for(int i=0; i<m[i].length;i++)
{k+=1;
for(int j=0;j<m.length;j++)
{vektor[k]=m[i][j];
k+=1;}
for(int a=0;a<vektor.length;a++)
System.out.println(vektor[a]);}

}

}

Announcements - What's Wrong With My Code?

Welcome to the Forum! Please read this topic to learn how to post your code correctly along with other useful info for newcomers.

```import java.swing.*;
import java.math.*;
public class KonvertoMatricenNeVektor {

public static void main(String[] args)
{int a =new Integer (JOptionPane.showInputDialog("Jepni numrin e rreshtave")).intValue();
int b= new Integer(JOptionPane.showInputDialog("Jepni numrin e shtyllave")).intValue();
int matrica [][]=new int [a][b];
for(int i=0; i<b; i++)
{for(int j=0; j<a; j++)
matrica[i][j]=(int) ((int) Math.random()*10);
vektor(matrica);}}
public static void vektor(int[][]m)
{int rr=0;
int sh=0;
for(int i=0;i<m.length;i++)
{	rr+=1;
for(int j=0;j<m[i].length;j++)
sh+=1;}
int vektor[]=new int[rr*sh];
int k=0;
for(int i=0; i<m[i].length;i++)
{k+=1;
for(int j=0;j<m.length;j++)
{vektor[k]=m[i][j];
k+=1;}
for(int a=0;a<vektor.length;a++)
System.out.println(vektor[a]);}

}

}```