title: Setting the nibble for an int - java
body: <p>I have to set the nibble for an integer using java. Honestly I am confused on how to shift/set/change a nibble to an nibble that I want. My TA told me it is supposed to be about 5 lines of code but I don't know how to even start it. Any help is greatly appreciated.</p>
  
  <pre><code>/* Examples:
   *     setNibble(0xAAA5, 0x1, 0); // =&gt; 0xAAA1
   *     setNibble(0x56B2, 0xF, 3); // =&gt; 0xF6B2
   * 
   * @param num The int that will be modified.
   * @param nibble The nibble to insert into the integer.
   * @param which Selects which nibble to modify - 0 for least-significant nibble.
   *            
   * @return The modified int.
   */
   public static int setNibble(int num, int nibble, int which) {
        // i know I will be using bit-wise operators but do not know how to use
        // them in this situation
        return 0;
   }
  </code></pre>