URL: https://alpha.linuxfr.org/forums/programmationjava/posts/static-or-not-static Title: Static or not static Authors: Ontologia Date: 2006年10月11日T16:21:01+02:00 Tags: testtag Score: 0 Bonjour, malgré avoir pris connaissance de la définition, je ne comprend toujours rien à ces histoires de static en java. Aujourd'hui, j'ai le code suivant : private boolean VerifExistanceFichierXML(String PthSrc, String NomFichierATrouver) { £spaces£ £/spaces£ £spaces£ £/spaces£String FichierTrouve = ""; £spaces£ £/spaces£String tmp=NomFichierATrouver ; £spaces£ £/spaces£boolean result=false; £spaces£ £/spaces£ £spaces£ £/spaces£File repertoire = new File(PthSrc); £spaces£ £/spaces£if ( repertoire.isDirectory ( ) ) { £spaces£ £/spaces£File[] list = repertoire.listFiles(); £spaces£ £/spaces£for ( int i = 0; (i < list.length || result == false); i++) { £spaces£ £/spaces£// Appel récursif sur les sous-répertoires £spaces£ £/spaces£FichierTrouve = list[i].getName(); £spaces£ £/spaces£Pattern pattern = Pattern.compile(FichierTrouve); £spaces£ £/spaces£Matcher matcher; £spaces£ £/spaces£matcher = Pattern.matcher((tmp.subSequence(0,tmp.length()))); £spaces£ £/spaces£boolean b = matcher.matches(); £spaces£ £/spaces£if (b) { £spaces£ £/spaces£result = true; £spaces£ £/spaces£} £spaces£ £/spaces£ £spaces£ £/spaces£} £spaces£ £/spaces£} £spaces£ £/spaces£ £spaces£ £/spaces£return result; £spaces£ £/spaces£} Et eclipse me crache Severity Description Resource In Folder Location Creation Time 2 Cannot make a static reference to the non-static method matcher(CharSequence) from the type Pattern Xml_arbo_reader.java Nomad_editor line 89 11 octobre 2006 16:11:47 Bien évidemment, avant ça j'avais collé directement NomFichierATrouver en paramètre à Pattern.matcher. Je voudrais bien savoir, c'est quoi ce langage, où tu peux même pas coller une variable récupéré en paramètre pour la coller en paramètre dans une fonction ? Merci de votre éclairage.

AltStyle によって変換されたページ (->オリジナル) /