Home » c# » c# – How do I find package names for java classes when I don't know what package it's in?-Exceptionshub

c# – How do I find package names for java classes when I don't know what package it's in?-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

What is an easy way to find what package to import when you know the name of the class, but don’t know what package it’s found in?

This drives me nuts, and I waste a lot of time. For example … I have a bit of example code

    String[] people = wholeFile.Split(
        new String[] { Environment.NewLine + Environment.NewLine },
                       StringSplitOptions.RemoveEmptyEntries
    );        

But I have no idea where to locate Environment or StringSplitOptions.

People post examples of code, and that’s great. But I waste time trying to figure out what package holds the classes afterwards. In this case … I couldn’t figure it out at all. What’s the use of code examples when you have no clue what package to import? No search I’ve found resolves where to find a class you know the name of, but not what package you have to import to use it.

I shouldn’t have to post here and say “What package is so and so found in …”

So, what package is StringSplitOptions found in … and Environment …

There has to be an easier way to resolve knowing a class name, but needing to find what package to import to use it.

How to&Answers:

The code you’ve posted is C#, not Java. They have very similar syntax, so the mistake is understandable.

My usual solution to this problem is google. When I googled “java Environment.NewLine” the first result was a question about finding the Java equivalent for that in C#. I found something similar when googling “java StringSplitOptions”. The only reasonable conclusion, then, is that this isn’t Java code.