Hola, aquí esta la respuesta a la pregunta.Cuando ponemos la suma total de 12 bits, que es el número de modificadores que existen, nos da 4095 =1+2+4+8+16+32+64+128+256+512+1024+2048, como está puesto en el código funcionaria correctamente.
|
ÕÖ×public class ModificadorPrueba{ |
Pero en efecto si nos pasamos de la cuenta no existen modificadores que lleguen a ese valor en binario, entonces es obvio que no nos salga nada.
| ÕÖ×public class ModificadorPrueba{ ÏϧÏÞßàpublic static void main(String[] args){ ÏϧÏϨ¹íÏint mod=4096; /*1000000000000=4096 */ ÏϧÏϨ¹¹ÏSystem.out.println(Modificador.toString(mod)); ÏϧÏϧ ÏϧÏÏ©} ÏÏ©} |
Todo lo que te hemos dicho esta tambien explicado en el método toString de la clase Modifier, en el API de java
|
toString public static String toString(int mod)Return a string describing the access modifier flags in the specified modifier. For example: public final synchronized strictfp The modifier names are returned in an order consistent with the suggested modifier orderings given in The Java Language Specification, Second Edition sections §8.1.1, §8.3.1, §8.4.3, §8.8.3, and §9.1.1. The full modifier ordering used by this method is: public protected private abstract static final transient volatile synchronized native strictfp interface The interface modifier discussed in this class is not a true modifier in the Java language and it appears after all other modifiers listed by this method. This method may return a string of modifiers that are not valid modifiers of a Java entity; in other words, no checking is done on the possible validity of the combination of modifiers represented by the input. Parameters: mod – a set of modifiers Returns: a string representation of the set of modifiers represented by mod |

Ok! Muchas gracias… Mi duda era eso que habeis dicho de que la clase Modifier no asigna ningún bit por encima del 2048 y por eso no puede sumarle ninguno al sobrepasar la suma d todos(4095).
Agur.
Por: Pachi el Marzo 18, 2008
a las 6:56 pm