Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

104
Vistas
¿Es posible establecer bits al crear un BitSet?

Necesito crear algunos BitSets en un bucle, algo como:

 ArrayList<BitSet> bitSetList = new ArrayList<BitSet>(); for (int x : array) { bitsetList.add(new BitSet() //and set bits in specific places) }
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

(Para crear un BitSet y establecer bits específicos) Puede usar uno de los siguientes:

  •  static BitSet valueOf(byte[] bytes) /** Returns a new bit set containing all the bits in the given byte array.**/
  •  static BitSet valueOf(long[] longs) /** Returns a new bit set containing all the bits in the given long array.*//
  •  static BitSet valueOf(ByteBuffer bb) /** Returns a new bit set containing all the bits in the given byte buffer between its position and limit.**/
  •  static BitSet valueOf(LongBuffer lb) /**Returns a new bit set containing all the bits in the given long buffer between its position and limit.**/

API-DOC: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/BitSet.html

over 4 years ago · Santiago Trujillo Denunciar

0

BitSet tiene varios métodos estáticos sobrecargados llamados valueOf con los que puede crear un BitSet con los bits configurados en ellos, por ejemplo, una matriz de byte :

 BitSet example = BitSet.valueOf(new byte[] { 0b101 }); System.out.println(example.get(0)); // Prints true System.out.println(example.get(1)); // Prints false System.out.println(example.get(2)); // Prints true

Consulte: https://docs.oracle.com/en/java/javase/14/docs/api/java.base/java/util/BitSet.html#valueOf(byte%5B%5D)

over 4 years ago · Santiago Trujillo Denunciar

0

Como cualquier otro objeto en Java, puede crear un objeto BitSet y agregarlo a una Lista de esta manera. Antes de agregarlo a la Lista, crearía el objeto BitSet y agregaría datos al objeto.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda