#How to create your initial class type?

32 messages · Page 1 of 1 (latest)

vocal creek
#

As far as you can see, in classes of primitive types of variables (String, Integer, Long ...) you can see a similar construction
public static final Class<String> TYPE = (Class<String>) Class.getPrimitiveClass("string"); I understand that it is responsible for creating a primitive class type (int, long...), I have a question how can i create my same type for my primitive class?

P.s I know that the question is not ordinary and complex, if you do not know the answer to this question or think that there is no solution to this, then just ignore it.
Or give a weighty argument

blazing gorgeBOT
#

This post has been reserved for your question.

Hey @vocal creek! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

drowsy ingot
#

String isn't primitive

#

and what do ylu mean with same type for primitive class?

blazing gorgeBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.

vocal creek
drowsy ingot
#

Java doesn't allow custom primitive types (yet)

#

although valhalla might change that

vocal creek
drowsy ingot
#

but that isn't in Java yet

vocal creek
drowsy ingot
#

Creating your own primitives that can be used from Java? No

#

But why would you need that?

vocal creek
drowsy ingot
#

Are they required to be primitives?

#

Or are records sufficient?

public record(String someString, int someInt){}
vocal creek
drowsy ingot
#

that's not possible

#

Java doesn't allow more primitives

#

If you tell me why you need it, I might be able to help you find a good way around it

vocal creek
drowsy ingot
#

the only way to get custom primitives to work with Java is using an early-access Valhalla build - and if you do that, others cannot use it and it might break at any point

drowsy ingot
vocal creek
drowsy ingot
#

note that Valhalla might still take a few years to be at that point

#

But I don't think you want to create your own JDK which won't be compatible/violates the specs