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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:54:04+00:00 2026-05-26T23:54:04+00:00

I have two classes (CoinFlip and Incr) in different files and I’m trying to

  • 0

I have two classes (CoinFlip and Incr) in different files and I’m trying to import Incr to use in CoinFlip:

package com.iRprojects.Book.Java;

import java.util.*; 
import com.iRprojects.Book.Java.*;

public class CoinFlip { 

    public static void main(String[] args) {
        int g = 5;

        System.out.println(incr(g));

    }
}   

and

package com.iRprojects.Book.Java;

public class Incr {
    public static int incr(int i){
        i++;
        return i;
    }
}

With the classes like this eclipse says incr() isn’t found.

If I change it to:

package com.iRprojects.Book.Java;

import java.util.*; 
//import com.iRprojects.Book.Java.*;

public class CoinFlip { 

    public static void main(String[] args) {
        int g = 5;

        System.out.println(com.iRprojects.Book.Java.Incr.incr(g));

    }
}   

It compiles fine.
Any ideas?

  • 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-26T23:54:05+00:00Added an answer on May 26, 2026 at 11:54 pm

    In this case you have to write:

    import static com.iRprojects.Book.Java.Incr.*;
    

    This means import of all static members from com.iRprojects.Book.Java.Incr class taking into account the access modifiers.

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

Sidebar

Related Questions

I have two classes defined in different h files and each class has some
I have two classes : import android.cla; public class CW { public static void
I have two classes Teacher and Student . I am trying to get teacher
I have two classes(Book,Software) that inherit from the Product class. these two classes have
I have two classes in a different projects. I am importing the project that
I have two classes, Phone.class and Time.class. I would like to use their methods
I have two classes Foo and Bar mapped to two different tables, and I'd
I have two classes in same package. i have declared a static variable in
I have two classes A and B in two different .NET assemblies: AssemblyA and
I have two classes, but don't what kind of relation i should use. 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.