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

  • Home
  • SEARCH
  • 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 6025923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:22:15+00:00 2026-05-23T04:22:15+00:00

List CreateNewStatements(ForLoop L) { List stmts = new ArrayList(); FlatIterator iter = new FlatIterator(L.getBody());

  • 0
List CreateNewStatements(ForLoop L)
{
    List stmts = new ArrayList();
    FlatIterator iter = new FlatIterator(L.getBody());

    Traversable t1 = null;

    LoopUnroll l = new LoopUnroll(t1);

    while(iter.hasNext())
    {
        stmts.add(iter.next().clone());
    }
    return stmts;
}

The above code is giving the error as “The method clone() from the type Object is not visible”.

In the above code, iter.next() returns a statement(Eg. fx[i] = fx[i] + x) of type Object(built in into java library) using which I want to call the method clone(). The above code is written in a class LoopUnroll and clone() is a method defined in the class Statement.

  • 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-23T04:22:16+00:00Added an answer on May 23, 2026 at 4:22 am

    clone() is protected on Object for exactly this reason – that you can’t just call it on arbitrary objects. It’s a bit of a hack, so that all classes can inherit the implementation of the method, but don’t expose that behaviour by default. (See Why is the clone method protected in java.lang.Object? for more details.)

    Anyway, if you actually want instances of your Statement class to be cloneable, you should do two things:

    1. Ensure the class implements Cloneable
    2. Redefine the clone method as public, and just defer to the superclass implementation. (This also gives you the chance to use covariant return types to prevent callers having to cast in most cases).

    The latter is what actually makes the clone method visible, and would look something the following:

    @Override
    public Statement clone() {
        return (Statement)super.clone();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

List<String> listA = new ArrayList<String>(); listA.add(a); listA.add(b); listA.add(c); listA.add(d); List<String> listB = new ArrayList<String>();
List l = new ArrayList<Number>(); List<String> ls = l; // unchecked warning l.add(0, new
List<tinyClass> ids = new List<tinyClass(); ids.Add(new tinyClass(1, 2)); bool b = ids.IndexOf(new tinyClass(1, 2))
List <Customer> collCustList = new List<Customer>(); I tried if(A==B) collCustList.Add(new Customer(99, H, P)); else
List<T> list = new ArrayList<T>(); 1 method: for(int i = list.length - 1; i
List New Class takes up memory? Do I need C=null; in the code below?
List itemsToMove = new List(); foreach (ListViewItem item in lvScanRepository.SelectedItems) { itemsToMove.Add(item); } foreach
List<Question> questions = new ArrayList<Question>(); questions.addAll(getAllQuestions()); //returns a set of Questions Collections.sort(questions, new BeanComparator(questionId));
List<string> list = new List<string>(); list.Add(A); list.Add(B); List<string> list1 = new List<string>(); list.Add(a); list.Add(b);
List<string> list1 = new List<string>(); list1.Add(Blah); list1.Add(Bleh); list1.Add(Blih); List<string> list2 = new List<string>(); list2.Add(Ooga);

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.