-2

This question already has an answer here:

It seems the syntax highlighter is not able to handle Java.

Any idea how to help fix this?

A sample code is below, and link1 and links2 in stackoverflow.

try (Statement stmt = con.createStatement()) {
    ResultSet rs = stmt.executeQuery(query);

    while (rs.next()) {
        String coffeeName = rs.getString("COF_NAME");
        int supplierID = rs.getInt("SUP_ID");
        float price = rs.getFloat("PRICE");
        int sales = rs.getInt("SALES");
        int total = rs.getInt("TOTAL");

        System.out.println(coffeeName + ", " + supplierID + ", " + 
                           price + ", " + sales + ", " + total);
    }
}

EDIT: Well, it seems syntax highlighter doesn't work in stackexchange, but in stackoverlow instead.

For the same case: most of the times, it doesn't work, e.g.

Without Highlighter

And now it does

With Highlighter

marked as duplicate by Community May 5 '15 at 15:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What code is wrongly formatted? – Patrick Hofman May 5 '15 at 12:44
  • Actually, I visited link1 now, and it is fine, although I have it in another window as not highlighted!!!! – Ahmed Ashour May 5 '15 at 12:45
  • You should have asked this on Meta Stack Overflow rather than here as it's about Stack Overflow – Robert Longson May 5 '15 at 13:17
  • Thanks for hinting – Ahmed Ashour May 5 '15 at 13:19
8

Code formatting is based on the language. The language is determined from the tag on the question.

In this case, the question didn't have the java tag. Once added, it recognized the language and the syntax highlighting works.

Or add the language in the post by putting this in:

<!-- language: lang-java -->

try (Statement stmt = con.createStatement()) {
    ResultSet rs = stmt.executeQuery(query);

    while (rs.next()) {
        String coffeeName = rs.getString("COF_NAME");
        int supplierID = rs.getInt("SUP_ID");
        float price = rs.getFloat("PRICE");
        int sales = rs.getInt("SALES");
        int total = rs.getInt("TOTAL");

        System.out.println(coffeeName + ", " + supplierID + ", " + 
                           price + ", " + sales + ", " + total);
    }
}

Not the answer you're looking for? Browse other questions tagged .