Share to get the Prefix from Salesforce’s ObjectName.
Execute the following on the “Open Execute Anonymous Window” screen of the “Debug” tab on the development console screen.
String objName ='Account';
schema.sObjectType sObjType = Schema.getGlobalDescribe().get(objName);
system.debug('prefix:'+(sObjType.getDescribe().getKeyPrefix()));
The DebugLog result is below.
prefix:001