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.

Filtered HTML

Plain text

CAPTCHA
Cette question permet de vérifier que vous n'êtes pas un robot spammeur :-)
  QQQ     GGG   V     V  L     Y   Y 
Q Q G V V L Y Y
Q Q G GG V V L Y
Q QQ G G V V L Y
QQQQ GGG V LLLL Y
Q