From 32ec759aa6c22f42296b7038f3b80854f230a694 Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Sun, 15 Oct 2023 20:07:03 +0200 Subject: [PATCH] =?UTF-8?q?Exercice=202.1:=20Fonction=20Avec=20Template=20?= =?UTF-8?q?pour=20AfficheTableau.=20Utilisation=20de=20type=20Short=20et?= =?UTF-8?q?=20Character=20=C3=A0=20la=20place=20de=20'short'=20et=20'char'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .classpath | 5 ----- src/exercice2part1.java | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) delete mode 100644 .classpath create mode 100644 src/exercice2part1.java diff --git a/.classpath b/.classpath deleted file mode 100644 index 25a5e3b..0000000 --- a/.classpath +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/exercice2part1.java b/src/exercice2part1.java new file mode 100644 index 0000000..39b41e9 --- /dev/null +++ b/src/exercice2part1.java @@ -0,0 +1,18 @@ +public class exercice2part1 { + public static void main(String[] argv) { + Short[] ConstTab = { 1, 2, 3, 4, 5 }; + Character[] MonTableau = new Character[5]; + for (int i = 0; i < MonTableau.length; i++) { + MonTableau[i] = (char) ('a' + (char) (i)); + } + afficheTableau(ConstTab); + afficheTableau(MonTableau); + } + + public static void afficheTableau(T[] array) { + for (T element : array) { + System.out.print(element + " "); + } + System.out.println(); + } +}