Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static String getPackageName(Class<?> klass) {
        if (klass == null) {
            return null;
        }

        String className = klass.getName();
        if (className == null) {
            return null;
        }

        final int splitIndex = className.lastIndexOf('.');

        return className.substring(0, splitIndex);
    }
}