Question
Can someone tell me what is wrong with this code and how to fix it? import components.simplereader.SimpleReader; import components.simplereader.SimpleReader1L; import components.simplewriter.SimpleWriter; import components.simplewriter.SimpleWriter1L; import components.xmltree.XMLTree;
Can someone tell me what is wrong with this code and how to fix it?
import components.simplereader.SimpleReader; import components.simplereader.SimpleReader1L; import components.simplewriter.SimpleWriter; import components.simplewriter.SimpleWriter1L; import components.xmltree.XMLTree; import components.xmltree.XMLTree1;
/** * Put a short phrase describing the program here. * * @author Put your name here * */ public final class longestText {
/** * Private constructor so this utility class cannot be instantiated. */ private LeafCount() { }
private static String longestText(XMLTree t) {
String longest = ""; int max = 0; int count = 0; if (t.isTag()) { for (int i = 0; i < t.numberOfChildren(); i++) { longest = longestText(t.child(i)); if (!t.child(i).isTag()) { count = t.child(i).label().length(); if (count > longest.length()) { longest = t.child(i).label();
}
}
}
}
return longest; }
public static void main(String[] args) { SimpleReader in = new SimpleReader1L(); SimpleWriter out = new SimpleWriter1L();
out.println("Please enter an RSS link: "); String web = in.nextLine();
XMLTree xml = new XMLTree1(web);
String word = longestText(xml); out.println(word); in.close(); out.close(); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started