Ajouter un commentaire

tiger360
exercices sur les tableaux

voila l enonce:
Ecrire une fonction dénommée chaîneTableau prenant en paramètre un tableau d'entiers à une
dimension. Et retournant une Chaîne qui représente les éléments du tableau.

je vois pas trop comment faire
je suis un debutant c est ma premiere annee

import java.util.Scanner ;
public class Ex5  {
    public static void main ( String[] args ) {
        Scanner clavier = new Scanner ( System.in ) ;

        int taille,nbr;
        String chaine;
        System.out.println("Introduisez la taille du tableau: ");
        taille=clavier.nextInt();
        int[] tab=new int[taille];

        for (int i=0;i<tab.length;i++)
        {
            System.out.print("Introduisez un nombre: ");
            nbr=clavier.nextInt();
            tab[i]=nbr;
        }
       chaine=chaineTableau(tab);
       System.out.println(chaine+" ");
    }

    public static String chaineTableau (int[] tab)
    {
        String chaine;
        for (int i=0;i<tab.length;i++)
        {
            chaine=tab[i] ;
            return chaine;
        }
    }
}

Cordialement.

CAPTCHA
Cette question permet de vérifier que vous n'êtes pas un robot spammeur :-)
 FFFF   QQQ    BBBB    GGG   U   U 
F Q Q B B G U U
FFF Q Q BBBB G GG U U
F Q QQ B B G G U U
F QQQQ BBBB GGG UUU
Q