Preciso de ajuda...como transformar valores de um vetor em um numero?

2 respostas
A

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?

2 Respostas

nel

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?

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.

A

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?

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;
				
			}
}
}
Criado 24 de janeiro de 2012
Ultima resposta 24 de jan. de 2012
Respostas 2
Participantes 2