• Notice regarding image hosts and attachments. See here.

Java help.

Caporegime
Joined
12 Mar 2004
Posts
29,964
Location
England
Keeps saying it can't find the variable "phone1", but it's decleared right above it!?

Code:
import GSMNetwork.*;

public class send {	
	public static void main(String[] args) {
		try {
			MobilePhone phone1 = new MobilePhone("0123456789");
		} catch (NetworkNotAvailableException nna) {
			System.out.println("Network not available!");
			System.exit(1);
		}
		TextMessage txt = new TextMessage("Hi");
		phone1.sendMessage(txt, "9876543210");
	}
}
 
I tried that earlier, but then I get, "phone1 might not have been initialised" and "unreported exception: phonenotinserviceexception, must be caught or declared to be thrown".
 
Fixes the initialisation error :). The other error was caused the sendMessage method, fixed that now. :)
 
Last edited:
Back
Top Bottom