I don't know how to use it as I read java doc it is something like Class<? extends Object> ..what does it mean?
I need to know what class is that and need to do something like this
Expand|Select|Wrap|Line Numbers
Class whatClass;
if (whatClass == BigInteger.class)
{ do something ....}
Please share the correct syntax with me....Thank You
class GetTheClass
{
public static void main(String[] args)
{
Object obj = new Object();
String s = new String();
System.out.println(s.getClass());
System.out.println(obj.getClass());
}
}
It returns the classname of the object u used to call that method.
class GetTheClass
{
public static void main(String[] args)
{
Object obj = new Object();
String s = new String();
System.out.println(s.getClass());
System.out.println(obj.getClass());
}
}
It returns the classname of the object u used to call that method.
you can use this to know the classname
thank you...
One more thing can I get something like this:
Expand|Select|Wrap|Line Numbers
if (className == jonmath.java.math.MyBigInteger)
{ //I need to do something only for this class.
//Do I need to initialize it? something like this?
// Class intClass = jonmath.java.math.MyBigInteger.class;
if (className instanceof jonmath.java.math.MyBigInteger) {
// ...
}
But if your code is going to be full of instanceof operators, you definatelly have a design flaw.
by doing that - compiler gives error: inverconvertible types
found : java.lang.Class
required: jonmath.java.math.MyBigInteger
Thanks for your reply....
by doing that - compiler gives error: inverconvertible types
found : java.lang.Class
required: jonmath.java.math.MyBigInteger
Thanks for your reply....
Ah, I see. Run this demo to see how the instanceof operator is used:
Expand|Select|Wrap|Line Numbers
public class InstanceofDemo {
public static void main(String[] args) {
String s = "a string";
Integer i = new Integer(1);
checkWithInstanceof(s);
checkWithInstanceof(i);
checkWithInstanceof(String.class);
checkWithInstanceof(null);
}
public static void checkWithInstanceof(Object o) {
Are primitives objects?
int i = 3;
System.out.println(i.getClass());
doesn't compile. Get an error message
"int can't be dereferenced"
But yet the docs for class Object say:
Class Object...
I refined my attempt a little further, and the following code does
seem to work, however it has 2 major problems:
1. Very limited support for XPath features
Basic paths are supported for...
I have been doing some reading on dynamic bindind and polymorphism. I
know the basics from what I have seen in books. The way virtual
methods were explained was that they were used when methods...
A deffinite bug in mscorwks.dll makes my managed service crash abruptly.
When hooking up windbg it turns out to be an "access violation" in the
mscorwks assembly memory space. Every time it happens...
Hello
This seems a simple question, please send me to the right FAQ if I
missed it:
If there is a class Fruits with two classes Apples and Bananas extending
Fruits. Apples has a method called...
I am trying to modify my program to add and delete inventory items. I tried just adding but I am getting mutliple errors help.
This is what my program currently looks like
// Display The...
Hi,
I'm very new to java... and I'm having a problem in getting a URL
URL url;
url=getClass().getClassLoader().getResource(name);
System.out.println(url);
This code works well when I supply...
I am having diffuculties while trying to make the path of my files relative.
I am using an interface to hold my static variables in order not to mix them with my other codes , just implementing the...
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...