Extension

Extension - if(extension.equalsIgnoreCase".java"...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class Extension { public static void main(String[] args) { System.out.print("Enter a word: "); String filename = IO.readString(); int period = filename.lastIndexOf("."); if (period == -1) { System.out.println("Unknown file type."); return; } String extension = filename.substring(period);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (extension.equalsIgnoreCase(".java")) { System.out.println("Java program"); } else if (extension.equalsIgnoreCase(".class")) { System.out.println("compiled Java executable"); } else { System.out.println("Unknown extension"); } } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online