Posts

Showing posts from May, 2025

Literal table

 #code import java.util.*; class Literal {     String value;     int address;     public Literal(String value) {         this.value = value;         this.address = -1; // not assigned yet     } } public class Ass2{     // Check if a literal already exists in the list     public static boolean literalExists(List<Literal> list, String value) {         for (Literal l : list) {             if (l.value.equals(value)) return true;         }         return false;     }     public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);         List<String> code = new ArrayList<>();         List<Literal> literalTable = new ArrayList<>();         Lis...