private void collectWarnings(SQLWarning warning,List<Warning> messages){
  while (warning != null) {
    messages.add(new Warning(warning.getSQLState(),warning.getMessage()));
    warning=warning.getNextWarning();
  }
}

private void collectWarnings ( SQLWarning warning , List < Warning > messages ) { while ( warning != null ) { messages . add ( new Warning ( warning . getSQLState ( ) , warning . getMessage ( ) ) ) ; warning = warning . getNextWarning ( ) ; } }
add the warning message from the specified warning , as well as any additional warnings linked via the getnextwarning method , to the list of messages .
