Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I am new to this, I have this:
public Builder id (String val) { id = val; return this; }
from below if statement i want to set builder id = 1ac. How can I do that. Thank you
if (blah blah) { id = "1ac"; }
I think you're looking for:
if(someCondition) builder.id("1ac");
The id method is written so that you pass it the value you want to set and then it returns this so you can chain calls together to set different values with a single statement.
id
this
Add a comment
I think you're looking for something more like this:
String idNew; public Builder id( String val ) { idNew = val; return idNew; } if(blah blah) { id("1ac"); }
Or, of course, what the guy above me said. Either or.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.