Line length more than 125

I have witten a line of code and the length is 126 character so i want to know if I am permitted to do something like this

if (attribute.getAttributeType().getMaxOccurs() != null && attribute.getAttributeType().getMaxOccurs() != 1) {


if (attribute.getAttributeType().getMaxOccurs() != null 
&& attribute.getAttributeType().getMaxOccurs() != 1) {

This is my personal preference. 80 characters isn’t always hard and fast…


if (attribute.getAttributeType().
   getMaxOccurs() != null && 
   getMaxOccurs() != 1) {
1 Like

Thank you for your feedback

These aren’t hard and fast rules either.

I quickly jumped to hoping to find a recommendation for that but did not. :slight_smile:

I would also go for @r0bby’s preference. :smile:

1 Like

As you have chained 2 method calls, what I would do is, take it to a local variable and use it. It increases the readability while reducing the line length. :smiley_cat:

Integer attrMaxOccrs = attribute.getAttributeType().getMaxOccurs();

if (attrMaxOccrs  != null && attrMaxOccrs  != 1) {


@judeniroshan that is a nice addition. :smile:

That works, I’d still put the conditionals on separate lines.

yeah judeniroshan I think that’s a good solution

FYI @lehone <- That’s how you mention somebody :wink:

thanks for the tip