Ola pessoal,
Eu montei um vetor bidimensional, e suas colunas sao preenchidas por valores randomicos 0 e 1. Gostaria de transfomar essas colunas em strings . alguem sabe como?
Ola pessoal,
Eu montei um vetor bidimensional, e suas colunas sao preenchidas por valores randomicos 0 e 1. Gostaria de transfomar essas colunas em strings . alguem sabe como?
[quote=alana.gim]Ola pessoal,
Eu montei um vetor bidimensional, e suas colunas sao preenchidas por valores randomicos 0 e 1. Gostaria de transfomar essas colunas em strings . alguem sabe como?
[/quote]
Em qual formato de String você precisa/quer?
Podes dar um exemplo da sua matriz para vermos?
De qualquer forma, dá uma olhada na classe Arrays.
NA verdade o que precio fazer e transformar as colunas dessa matriz que sao numeros binários em um numeros reais. nao sei como. alguem sabe?
[code]import java.lang.Object;
import java.util.Random;
import java.math.*;
public class dataStructure {
private static final int MAXPOP = 100;
private static final int MAXSTRING = 30;
/**
*
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/**Array Bidimensional Linhas = População & Colunas Strings*/
int [] [] Population = new int [MAXSTRING][MAXPOP];
/** Real value of the string*/
//int x;
/** Objective function value*/
//int fitness;
/** Variable to population size*/
// int popsize;
/** Variable to string length*/
//int lstring;
/** Variable to generation counter*/
//int t;
/** Variable upper limit on the number of generations*/
//int maxgen;
int i;
int j;
//Randomiza as Strings
Random allele = new Random();
for ( i=0; i<MAXSTRING; i++){
for (j=1; j<MAXPOP; j++){
int y = allele.nextInt(2);
Population[i][j] = y;
}
}
//Enumera as populacaoes
for(int a=0; a<MAXPOP; a++){
Population[0][a]=a;
}
}
}
[/code]