문제

I am trying to concatenate two strings using groovy shell but it's not working

   groovy.shell("def name = 'MyName'; def fname = 'firstName'; println name+fname" );

But for single string this is working

   groovy.shell("def name ='MyName'; println name");

Any idea about this?

도움이 되었습니까?

해결책

You can Use StringBuilder as below Object value = shell.evaluate("def name= new StringBuilder('James'); def fname= new StringBuilder('abd'); println name.append(fname) ;");

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top