File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes unclosed string literal error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "unclosed string literal error" Watch "unclosed string literal error" New topic

unclosed string literal error

Hunter Simington

Joined: Jul 05, 2006
Posts: 2
Here is my code

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

String[] wordListOne = {"24/7", "multi-Tier", "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", "core-competency", "strategy", "mindshare", "portal", "space", "vision", "paradigm", "mission"};

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

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

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

System.out.println("What we need is a " + phrase);

//In the first string the error tells me it expects '}' but I don't know where to put it. the second error says unclosed string literal
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2398
That just means you've probably got mismatched " and ". Make sure that for each String literal, you have " before and after.
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
should be

MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

You'll have to correct that one too:

[My Blog]
All roads lead to JavaRanch
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
critical-path is missing the opening "

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I agree. Here's the link:
subject: unclosed string literal error
It's not a secret anymore!