JMBeaucoup
Messages postés16Date d'inscriptionsamedi 4 avril 2009StatutMembreDernière intervention24 juin 2009
-
8 avril 2009 à 11:27
JMBeaucoup
Messages postés16Date d'inscriptionsamedi 4 avril 2009StatutMembreDernière intervention24 juin 2009
-
8 avril 2009 à 20:05
Bonjour,
En voulant compiler mon code, un message d'erreur vient ce claquer sur mon écran.
Le message est: Could not find the main class:javax.baja.naming.BIpHost. Program will exit.
Seulement là je vois pas! J'ai fais attention à tout, enfin je croix :) et il me semble plutôt propre mon code non??? pourquoi ne voit-il pas mon main?
Voici mon code:
/**
* Tri d'un tableau d'entier en échangeant la valeur des éléments.
*/
import java.io.IOException;
public class TrieParEchange
{
public void main() throws IOException {
//public static void main(String args[]) throws IOException {
int tab [] = { 2, 5, 1, 3, 0, 4};
int i,j ;
i=0;
j=0;
j=i;
// Affichage du tableau à trier.
System.out.println("Affichage du tableau à trier");
TrieParEchange.afficher(tab);
// Parcourir tableau,
for(i=0; i<tab.length; i++)
{
for(j=i+1; j<tab.length; j++)
{
if(i<j)
{
j++;
}
else if(i>j)
{
// Echange de deux valeurs.
int tmp = 0;
tab[i]=tmp;
tab[j]=tab[i];
tab[j]=tmp;
}
}
}
// Affichage du tableau trier.
System.out.println("Affichage du tableau trier");
TrieParEchange.afficher(tab);
}
//Affichage à l'écran
public static void afficher(int tab[])
{
for(int a=0; a<tab.length; a++)
System.out.println(tab[a]);
return;
}
}
cs_irraxen
Messages postés4Date d'inscriptionmercredi 30 avril 2003StatutMembreDernière intervention11 juin 2009 8 avril 2009 à 13:05
Bonjour,
Ta méthode main fonctionnerait mieux si elle était "static"
exemple : public static void main(String args[]) throws IOException {
--------------------------------------------------------------------------
si tu tape ta tête contre une cruche et que cela sonne creux n'en déduis pas obligatoirement que c'est la cruche qui est creuse