Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

if statement with question mark

807601Jun 26 2008 — edited Jun 26 2008
Hey. From what i remember there are two ways of implementing if-statements. 1: The classic way with if(this is true){do this}, and 2: the less used way to implement it at one line using a question mark. Im trying to understand a bit of code where number 2 is used inside a number 1 (messy code..?), but i cant get it. As you probably understand, recordNum is an int, cb.getValue returns true/false and the .split is splitting a String into a String[] where there are tab's appearing. Can anyone easily explain whats happening here, of maybe rewrite it with only number 1 if-statements? Thanks :)
for(int i = 0;i < recordNum;i++) {
	    	if(dataLine[(cb.getValue())?(i+1):i].split("	").length<=1) {
	    	
	    	}
	    	else {
	    		String[] temp = dataLine[(cb.getValue())?(i+1):i].split("	");
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 24 2008
Added on Jun 26 2008
2 comments
294 views