JSimoes Posted November 15, 2007 at 05:03 PM Report Share #147552 Posted November 15, 2007 at 05:03 PM Boa tarde. Como e que se acrescenta posições a um array? Por exemplo , ele ter 5 posições e pasasr a ter 7, e depois aumentar outra vez se for preciso, dentro de um for ou de um do while , por exemplo Obrigado Link to comment Share on other sites More sharing options...
magician Posted November 15, 2007 at 07:05 PM Report Share #147585 Posted November 15, 2007 at 07:05 PM Tens de o fazer manualmente pelo menos eu não de nenhuma actualização sobre isso. Vais ter de criar uma copia de cada uma das posições originais e colocar no novo array. Tens sempre a opção do Vector que é muito bom 🙂 http://java.sun.com/javase/6/docs/api/java/util/Vector.html I haven’t lost my mind; it’s backed up on DVD somewhere! Link to comment Share on other sites More sharing options...
javanoob Posted November 20, 2007 at 08:37 PM Report Share #148982 Posted November 20, 2007 at 08:37 PM Já agora, como é que se pode fazer isto: String[] abc = { "a", "b", "c" } for(int i=o; i<abc[c]; i++) ... Obrigado! Link to comment Share on other sites More sharing options...
magician Posted November 20, 2007 at 09:03 PM Report Share #148990 Posted November 20, 2007 at 09:03 PM não percebi a ideia :S Explica lá isso melhor. I haven’t lost my mind; it’s backed up on DVD somewhere! Link to comment Share on other sites More sharing options...
javanoob Posted November 20, 2007 at 09:37 PM Report Share #149007 Posted November 20, 2007 at 09:37 PM não percebi a ideia :S Explica lá isso melhor. A ideia era pegar numa string e verificar se uma outra string de um array existe na primeira e depois fazer um print até á string que verifica a condição. Algo como isto: ] public class Decompor { static String[] chars = { "k", "w", "y"}; static String string = ""; static int i=0; static int j=0; public static void decompoeString(String string) { for(i=0; i<chars.length; i++) { if(string.contains(chars[i])) { for(j=0; j<chars[i]; j++) {} System.out.print(string.charAt(i) + " "); } } } public static void main(String[] args) { string = args[0]; decompoeString(string); } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now