então pessoal estou com uma duvida, em como converter uma String para um Long, mas não posso usar parseLong do JAVA, eu tava tava pensando em usar um vetor.
Assim eu pensei em fazer
a[4]
b[4]
c[5]
d[6]
4 x 1000
4 x 100
5 x 10
1 x 1
ai no final soma td e imprime o valor para o usuario como long.
será q é por esse caminho?
String vetor [] = new string vetor [" "];
int vet;
for(int i = 0; i < string vetor.length();i++){
// não tenho certesa ainda mas acho q é aqui q tem q
fazer if para somar os caracteres e depois imprimi o valor digitado ?
System.out.println( " valor digitado é ", i string vetor.charAt (i));
}
}
}
Desculpe os erros e tudo mais, mas não sei muito de JAVA e to fazendo de tudo aqui p resolve esse problema!
public class Main {
public static void main(String [] args) {
String numero = "129382312938";
long result = 0;
for (int i = 0; i < numero.length; i++) {
result = result * 10 + (letra.charAt(i) - 48); //O valor ascii do 0 é 48: http://www.asciitable.com/
}
System.out.println("O número é: " + result);
}
}
isso foi q eu tava tentando resolve, mas vc postouantes hehe
public static void main(String[] args) {
String vetor [] = new string vetor [" "];
int vet;
long total;
for(int i = 0; i < string vetor.length();i++){
vet [i] = vetor [i];
for(int i = 0; i < string vetor.length();i++){
long total = vet [0] * 1000
long total += vet [1] * 100
long total += vet [2] * 10
long total += vet [3] * 1
a += b equivale a: a = a+b
System.out.println( " valor digitado é ", i string vetor.charAt (i)));
}
}