user3554403
user3554403

Reputation: 11

Unable to declare Java Constants as static

I am getting error-"Illegal modifier for parameter DEFAULT_CATALOG, only final is permitted" in below (Bold part), Why I am not able to declare constant as static. Instead of directly using variable in my other class, I want to use contants. Kindly help.

package com.asc.scheduler.test;

import atg.adapter.gsa.query.Constant;

public class AscConstants {

    public static void schedulerContants(){

        **public static final String DEFAULT_CATALOG = "defaultCatalog";**

    }

}

Upvotes: 0

Views: 135

Answers (1)

Neil
Neil

Reputation: 5782

DEFAULT_CATALOG is a variable local to your method schedulerContants(). As such, it thinks DEFAULT_CATALOG is supposed to be a local variable, yet you added static modifier to it, which doesn't make sense. You probably meant to make that a member of AscConstants, so:

public class AscConstants {
    public static final String DEFAULT_CATALOG = "defaultCatalog";

    public static void schedulerConstants(){

    }
}

Upvotes: 9

Related Questions