title: How to get picture's hex code of every pixel and save as String
body: <p>I am trying to make a RPG game in Java and i have run into a problem when it comes to building the level. It is not getting the hexidecimal code correct. Here is the loop and switch statement that is in question:</p>
  
  <pre><code>public void loadLevel(BufferedImage levelImage){
      tiles = new int[levelImage.getWidth()][levelImage.getHeight()];
      for (int y = 0; y &lt; h; y++) {
          for (int x = 0; x &lt; w; x++) {
              Color c = new Color(levelImage.getRGB(x, y));
              String h = String.format("&amp;02x%02x%02x", c.getRed(),c.getGreen(),c.getBlue());
  
              switch(h){
              case "00ff00"://GRASS Tile - 1
                  tiles[x][y] = 1;
                  System.out.println("Found Grass");
                  break;
              case "808080"://Stone -2
                  tiles[x][y] = 2;
                  System.out.println("Found STONE");
                  break;
              case "894627"://Dirt -3
                  tiles[x][y] = 3;
                  break;
              case "404040"://Rock -4
                  tiles[x][y] = 4;
                  break;
              case "00b700"://Tree -5
                  tiles[x][y] = 5;
                  break;
              case"000000"://Wall -6
                  tiles[x][y] = 6;
                  break;
              default:
                  tiles[x][y] = 1;
                  System.out.println("Did not find anything");
                  System.out.println(h);
                  break;
  
              }
  </code></pre>
  
  <p>right now, the string is being set as some variation of <code>&amp;02x0000</code> Any ideas/revisions would be very helpful!</p>