Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 697147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:08:17+00:00 2026-05-14T03:08:17+00:00

class x{ public static void main(String[] args){ String x=<html><head></head></html>; String arr[]=x.split(<head>); String script=hi; x=arr[0]+<head>+script+arr[1];

  • 0
class x{
public static void main(String[] args){
    String x="<html><head></head></html>";
    String arr[]=x.split("<head>");
    String script="hi";
    x=arr[0]+"<head>"+script+arr[1];
    System.out.println(x);
}

}

the above code when compiled as a java file compiles fine but when used a s a groovy file spits the error :

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
D:\Garage\groovy-binary-1.7.1\groovy-1.7.1\bin\x.groovy: 4: Apparent variable ‘a
rr’ was found in a static scope but doesn’t refer to a local variable, static fi
eld or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable fro
m a static context.
You misspelled a classname or statically imported field. Please check the spelli
ng.
You attempted to use a method ‘arr’ but left out brackets in a place not allowed
by the grammar.
@ line 4, column 10.
String arr[]=x.split(“”);
^

D:\Garage\groovy-binary-1.7.1\groovy-1.7.1\bin\x.groovy: 6: Apparent variable ‘a
rr’ was found in a static scope but doesn’t refer to a local variable, static fi
eld or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable fro
m a static context.
You misspelled a classname or statically imported field. Please check the spelli
ng.
You attempted to use a method ‘arr’ but left out brackets in a place not allowed
by the grammar.
@ line 6, column 5.
x=arr[0]+””+script+arr[1];
^

D:\Garage\groovy-binary-1.7.1\groovy-1.7.1\bin\x.groovy: 6: Apparent variable ‘a
rr’ was found in a static scope but doesn’t refer to a local variable, static fi
eld or class. Possible causes:
You attempted to reference a variable in the binding or an instance variable fro
m a static context.
You misspelled a classname or statically imported field. Please check the spelli
ng.
You attempted to use a method ‘arr’ but left out brackets in a place not allowed
by the grammar.
@ line 6, column 28.
x=arr[0]+””+script+arr[1];
^

3 errors

D:\Garage\groovy-binary-1.7.1\groovy-1.7.1\bin>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:08:18+00:00Added an answer on May 14, 2026 at 3:08 am

    It works if you move the [] to the String side like so:

    String[] arr = x.split("<head>");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

class D { public static void main(String args[]) { Integer b2=128; Integer b3=128; System.out.println(b2==b3);
public class Foo { public static void main(String[] args) { float f; System.out.println(f); }
http://introcs.cs.princeton.edu/java/13flow/Sqrt.java.html : public class Sqrt { public static void main(String[] args) { // read
class Test { public static void main(String[] args) throws Exception { Test t =
public class Test { public static void main(String[] args) { DemoAbstractClass abstractClass = new
Example: public class TestClass { public static void main(String[] args) { TestClass t =
public class b { public static void main(String[] args) { byte b = 1;
public class Sample { public static void main(String[] args) { int year = 2012;
public class Loopname{ public static void main (String [] args){ String files []= new
public class I { public static void main(String args[]) { int i=0,j=1,k=2; i=i++ -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.