find - Java: Style-Correcting Code: finding comment -
i'm writing these algorithms style-correcting program makes adjustments java source file, can compile without error. set read file line-by-line.
right now, i'm having trouble writing 2 methods/algorithms which
- determine if current line (string) has comments, and
- finds comment starts
i have:
public static int findcomment (string textline) { int endofcode = textline.lastindexof("; "); return textline.indexof("//", endofcode); } public static boolean hascomment (string textline) { if (textline.contains("//")) { return true; } else { return false; } }
i know incorrect because can have code, , comments, contain " ; // ; //" comments. tried other conditional statements without success.
hello don't explain problem have think should escape backslash characters when working indexof function.
Comments
Post a Comment