Question: Why do I get the error message Could not find or load main class TextMsgExpander when I try to run this. The package name is

Why do I get the error message Could not find or load main class TextMsgExpander when I try to run this. The package name is textmsgexpander. What do I need to change in my file to get it to work. Thanks for your help... /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package textmsgexpander; import java.util.Scanner; /** * * @author jack */ public class TextMsgExpander { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here String txtMsg,mesg,replaced ; Scanner sc=new Scanner(System.in); String BFF="best friend forever"; String IDK="i don't know"; String TMI="too much information"; String LOL="laughing out loud"; String IMHO="in my humble opinion"; String TTYL="talk to you later"; System.out.print("Enter Text :"); txtMsg=sc.nextLine(); System.out.println("You Entered :"+txtMsg); if(txtMsg.contains("BFF")) { txtMsg=txtMsg.replace("BFF",BFF); System.out.println("Replaced 'BFF' with "+BFF); } if(txtMsg.contains("IDK")) { txtMsg=txtMsg.replace("IDK",IDK); System.out.println("Replaced 'IDK' with \""+IDK+"\""); } if(txtMsg.contains("TMI")) { txtMsg=txtMsg.replace("TMI",TMI); System.out.println("Replaced 'TMI' with \""+TMI+"\""); } if(txtMsg.contains("LOL")) { txtMsg=txtMsg.replace("LOL",LOL); System.out.println("Replaced 'LOL' with \""+LOL+"\""); } if(txtMsg.contains("IMHO")) { txtMsg=txtMsg.replace("IMHO",IMHO); System.out.println("Replaced 'IMHO' with \""+IMHO+"\""); } if(txtMsg.contains("TTYL")) { txtMsg=txtMsg.replace("TTYL",TTYL); System.out.println("Replaced 'TTYL' with \""+TTYL+"\""); } System.out.println("Expanded :"+txtMsg); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!