-6

Tried printing Hello. But nothing was printed on console. It returned the value as (void). Suggest a solution

Attached the expression as image.

@Service("DetailsDAO") 
public class DetailsDAOImpl implements DetailsDAO {

    private static final Logger logger = Logger.getLogger(DetailsDAOImpl.class);

    @Override 
    public List < DetailsVO > getDetails(String name) {
        System.out.println("Hello");
        logger.info("Hello");
        List < DetailsVO > detailList = new ArrayList < DetailsVO > ();
        DetailsVO detVo = new DetailsVO();
        detVo.setAdd1("abc");
        detVo.setAdd2("qwe");
        detailList.add(detVo);
        return detailList;
    }
}
Glains
  • 2,773
  • 3
  • 16
  • 30
Prakash
  • 1
  • 2
  • thats because the println call returns void. – jr593 Jul 24 '18 at 10:12
  • You are probably looking in the wrong place for your console output. It’s unlikely that it gets eaten somewhere. – Ole V.V. Jul 24 '18 at 10:20
  • So in eclipse, help me where can i find the console output. System.out.println("Hello") will be print on the console,right? – Prakash Jul 24 '18 at 10:32
  • @Prakash Are you sure you `getDetails` is called somewhere else, maybe another instance is `@Autowired` and then called? Could you provide and code calling the method? – Glains Jul 24 '18 at 11:19
  • It is not called anywhere. – Prakash Jul 24 '18 at 12:17
  • 1
    @Prakash If `getDetails` is not called anywhere, then why do you expect to see any output? – Glains Jul 24 '18 at 13:36

1 Answers1

-1

Your problem is not very clear and i suggest you post some code.

A simple Hello World program looks like this:

public class Main {

    public static void main(String [] args) {
        System.out.println("Hello World!");
    }
}

Please note that System.out.println does not return anything, it simply does what its name means: Print a line on the console.

Glains
  • 2,773
  • 3
  • 16
  • 30
  • It neither answers the question nor provides anything that is likely to be different from the asker’s own code in any significant way. – Ole V.V. Jul 24 '18 at 10:21
  • 2
    @OleV.V Then the question is probably not well-asked. Im voting to close this question now. – Glains Jul 24 '18 at 10:25
  • @Service("DetailsDAO") public class DetailsDAOImpl implements DetailsDAO{ private static final Logger logger = Logger.getLogger(DetailsDAOImpl.class); @Override public List getDetails(String name) { System.out.println("Hello"); logger.info("Hello"); List detailList=new ArrayList(); DetailsVO detVo = new DetailsVO(); detVo.setAdd1("abc"); detVo.setAdd2("qwe"); detailList.add(detVo); return detailList; } This is my code I tried logging with log4j also. No output in the console for both Sytem.out.println() and logger.info. – Prakash Jul 24 '18 at 10:35