Organizational Research By

Surprising Reserch Topic

Exception in thread “main” java.lang.Error: Unresolved compilation (PhraseOMatic)

I tried to run the code from Head First Java as the following:

public class PhraseOMatic {
   public static void main(String[] args){

    String[] wordListOne = {"24/7", "mult-iTier", "30,000 foot", "B-to-B", "win-win", "front-end", "web-based", "pervasive", "smart", "six-sigma", "critical-path", "dynamic"};

    String[] wordListTwo = {"empowered", "sticky", "value-added", "oriented", "centric", "distributed", "clustered", "branded", "outside-the-box", "positioned", "networked", "focused", "leveraged", "aligned", "targeted", "shared", "cooperative", "accelerated"};

    String[] wordListThree = {"process", "tipping-point", "solution", "architecture", "cor competency", "strategy", "mindshare", "portal", "space", "vision", "paradigm", "mission"};

    int oneLength = wordListOne.length;
    int twoLength = wordListTwo.length;
    int threeLength = wordListThree.length;

    int rand1 = (int) (Math.random() * oneLength);
    int rand2 = (int) (Math.random() * twoLength);
    int rand3 = (int) (Math.random() * twoLength);

    String phrase = wordListOne[rand1] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];

    System.out.println("What we need is a " + phrase);
and it is here that I receive this error:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

at PhraseOMatic.main(
I see from the error that the problem is in line 2, but I can identify the error

asked May 7, 2015 in Core java by rajesh
0 votes

Related Hot Questions

1 Answer

0 votes

Have a look at exception trace (PhraseOMatic.main( Your public class PhraseOMatic must be saved with file. Name of top-level public class and .java file must be same.

answered May 7, 2015 by rajesh