RandomAccessMemory implements Memory { private void writeByte(int address, int byteData) { byteData &= 0377; int wordData = readWord(address); if ((address & 1) == 0) { wordData &= 0177400; wordData |= byteData; } else { wordData &= 0377; wordData |= byteData << 8; } writeWord(address, wordData); } RandomAccessMemory(String id, int startAddress, int size, Type type);  RandomAccessMemory(String id, int startAddress, int size);  RandomAccessMemory(String id, int startAddress, short[] data);  RandomAccessMemory(String id, int startAddress, byte[] data); @Override String getId(); @Override int getStartAddress(); @Override int getSize(); @Override short[] getData(); void putData(short[] dataToPut); @Override int read(boolean isByteMode, int address); @Override boolean write(boolean isByteMode, int address, int value); @Override boolean isRelatedAddress(int address); @Override void saveState(Bundle outState); @Override void restoreState(Bundle inState); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString();  }
@Test public void testWriteByte() { byte[] ramData = new byte[] { 0, 0 }; RandomAccessMemory ram = new RandomAccessMemory("TestRam", 01000, ramData); ram.write(true, 01000, 1); assertEquals(1, ram.read(false, 01000)); ram.write(true, 01001, 0377); assertEquals((0377 << 8) + 1, ram.read(false, 01000)); ram.write(true, 01001, 0177777); assertEquals((0377 << 8) + 1, ram.read(false, 01000)); }