U can use StringBuffer ,
public
String getText(String no) throws Exception
{
StringBuffer Info = new StringBuffer ();
Info.append ( "<html>\n" );
Info.append ( "<body bgcolor='#FFFFEE'>\n" );
Info.append ( "<td>\n" );
Info.append ( str1[i]+"\n" );
Info.append ( "</td>\n" );
:
:
Info.append("<table>\n");
Info.toString();
}
Then u set it in tooltip
JLabel lab=new JLabel()
lab.setToolTipText(getText());