



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: Programming Concepts I; Subject: Computer Science ; University: University of Alaska - Anchorage; Term: Unknown 1989;
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




class DebugTest { public static final String STR = "some string here"; public static void main(String[] args) { String s; s = STR.substring(0,3); // Do some processing of the string s = STR.substring(1,5); // Do some processing of the string s = STR.substring(8,3); // Do some processing of the string s = STR.substring(22,4); // Do some processing of the string s = STR.substring(2,3); // Do some processing of the string return; } }
C:\homeworks>java DebugTest Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: - at java.lang.String.substring(String.java:1525) at DebugTest.main(DebugTest.java:10)
import java.util.Scanner; class DebugTest { public static void main(String[] args) { int fahr, celsius; Scanner keyboard = new Scanner(System.in);
System.out.println("Enter temperature in Fahrenheit."); fahr = keyboard.nextInt(); celsius = 5 / 9 * (fahr - 32); System.out.println("The temp in Celsius is " + celsius); } }
import java.util.Scanner; class DebugTest { public static void main(String[] args) { int fahr, celsius;