Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am currently working on a project where I found this syntax:
Method m = bluetoothDevice.getClass().getMethod("createBond", (Class[]) null);
What is the purpose of "Method" class in Java and why we use it? Please elaborate with an example
Thanks in advance!
PS: I already saw the Java docs but not able to understand it.
The Method class is part of the "reflection" API which is about meta-programming. That means you can deal with structures of your program as data and process it in a java program. This allows flexible generic or abstract solutions. Method itself just represents a method in a Java class. There are other classes representing other parts of Java programs, too (e.g. Class).
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
What is the difference between Collectors & Collector. I know that one is interface & one is class. I want to know with example what is the actual difference and When to use which one with real time example.
Hi all I already mentioned in my question I know the basic difference and I gone through the documentation also, I just want to know the purpose to introduce this two thing with example and When should use which one?
Collectors is just a class with static methods which create commonly used Collectors.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
So, I just finished my first program, but I haven't use any methods in it, since I'm just beginning to learn how to use them. Here's the original code : http://codepad.org/JiBfJI8Q I started to fractionate it but realised that it would be a method inside another all the way down. Is that actually the way to do it, or did I get the idea wrong?
without having looked at your code:
The general idea of methods is to separate small
portions of code which might be used at multiple other places in your code.
so yes, calling methods from within other methods is a good thing to do.
ideally your so called "composed methods" read out like a little story:
public void transaction(){
openDatabaseConnection();
addRecordsToDatabase();
closeDataseConnection();
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have patching class dynamycly by BCEL, and them I dynamycly reload class.
I`m not sure what I really reloading class.
How can I check it?
How can I view class bytecode without save it as file?
Thanks.
I'm not sure what I am really reloading the class. How can I check it?
Well, you could print a message to System.out in static initializer in your class. If the message is printed you will know that your class has been reloaded, and the (new) class has been initialized.
How can I view class bytecode without save it as file?
See Pretty printing a method in ASM Bytecode
Whether netbeans special instruments for it?
I don't know what you are asking here ...
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
For example in some Java programs we use main method at below the class
in some Java programs we use main method after at writing methods what is the difference?
There is no difference if we write main method first or last. All the java programs starts the execution from the main class and it is independent from position (first or last).
there is no different, but you have to put all methods in a class...
you can read the manual :-) https://docs.oracle.com/javase/tutorial/getStarted/application/
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
is there any way to search all methods in Java class with regex?
(public|protected|private|static|\s) +[\w\<\>\[\]]+\s+(\w+) *\([^\)]*\) *(\{?|[^;])
With this you can, but search before ask, because i only have used the search to find this answer ^^.
I think you're looking for reflection - see this tutorial for help. Only through reflection can you access information about loaded classes - unless you're thinking of loading in the .java file and analyzing its text.