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 8528419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:47:50+00:00 2026-06-11T08:47:50+00:00

I have following problem; I have inerface with public method clone(): public interface Something

  • 0

I have following problem;

I have inerface with public method clone():

public interface Something {
    Something clone();
}

and also

public class SomethingImpl implements Something {

        private Something some;

    public Something clone() {
        return some.clone();
    }
}

Whenewer I run from code somewhere

...
Something i =  new SomethingImpl();
...
// do something on i
...
someMethod(i);
...

public void someMethod(Something some){
    Something some2 = some.clone(); 
  }

I get Exception in thread “main” java.lang.NullPointerException on line Someting some2 = some.clone;

I programmed a lot bussiness logic, but never till now I encountered neccessity of cloning, esspecially this way.

Can someone point me in which direction I should go? I tried to read articles on this topic but just got more confused.

Thanks in advance,
Mile

  • 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-06-11T08:47:52+00:00Added an answer on June 11, 2026 at 8:47 am

    A method and a field are two different things. clone is a field, which is not defined and hence will not exist. clone() is a method. Did you mean Someting some2 = some.clone()?

    Edit I just saw your actual error (although what I said above should still be heeded!). This means that some must be null – are you perhaps changing its value in the portions of code you omitted? Be sure to check for that whenever you receive a NullPointerException.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a following problem I want to solve ellegantly: public interface IMyclass {
I have some tricky generic type problem involving reflection. Here's the code. public @interface
I have the following problem. Given a Interface EventNotifier for the Observer Pattern: public
I have different fruit class, all implements the same interface IFruit : public interface
Hi i have following Problem. I write a Mediawiki Extension where i need some
I have a problem in Java: I have an interface: public interface I extends
I have the following generic question Here is a my generic message interface. public
I have a method: public void StoreUsingKey<T>(T value) where T : class, new() {
I have the following code @Configurable(dependencyCheck = true) public class KnowledgeRequestServlet extends HttpServlet {
I have the following interface called IAccountService. I also have exactly the same interfaces

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.