(Spring boot) can Optional<> Class be like List<> Class?
问题 Im trying to put the RoomEntity Class in the List as its generic parameter but the List Class turns red(Error) and the only thing that it suggests is for me to change the List Class to Optional Class. public interface RoomRepository extends CrudRepository<RoomEntity, Long> { List<RoomEntity> findById(Long id); } RoomEntity Class @Entity @Table(name = "Room") public class RoomEntity { } are they the same? List<RoomEntity> findById(Long id); Optional<RoomEntity> findById(Long id); 回答1: Optional