Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

NetBeans and implementation of other compilers

OTG-467455Nov 22 2017 — edited Nov 30 2017

Although the true test of a programmers ability is by using the command line, NetBeans is a very good IDE and allows one to incorporate other features.

The features include C++, PHP, Java Card, Maven, etc.   Each of these require a compiter to be installed.

Which windows based C++ compiler would be the best with the simplest installation?

Which PHP version would be better to install and would this be from PHP.org or some other source?

When Java is activated are all the features such as Maven, Java Card, JavaFX, Debugger, Profiler and GUI available?

Comments

DrClap
Sure, that will work as long as the type in question has an accessible zero-argument constructor. So yes, in your example you could return a new ArrayList or a new HashSet. Not a new ArrayList<Thing>, though, because generics are a compile-time concept only and mean nothing at run time.

By the way it's more traditional to just pass a Class object directly, instead of a wasted object of that class:
public Class<?> method(Class<?> arg) {    
    Class<?> copy = arg.newInstance();
    return copy;
}
And to call that:
ArrayList result = method(ArrayList.class);
843793
@DrClap: shouldn't your method be:
public Object method(Class<?> arg) {    
    Object copy = arg.newInstance();
    return copy;
}
DrClap
Robert.Bossy wrote:
@DrClap: shouldn't your method be:
public Object method(Class<?> arg) {    
Object copy = arg.newInstance();
return copy;
}
Yes, you're right. Or perhaps something like
public T method(Class<? extends T> arg) {    
    T copy = arg.newInstance();
    return copy;
}
Although I have to say, this method doesn't look as useful to me as it apparently did to the OP.
1 - 3

Post Details

Added on Nov 22 2017
6 comments
295 views