how to develop java application without taking any user defined class? [closed]

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 11 years ago .

is it possible to create any application that can use only built-in classes? application like addition or another basic operations ex built in classes like class String<> class Object<>

asked Sep 12, 2013 at 19:04 jayeshbsk5 jayeshbsk5 1 1 1 bronze badge Yes, it's possible. Why? Commented Sep 12, 2013 at 19:05 If you don't count the application class itself, why not. Commented Sep 12, 2013 at 19:08 Actually all you need for ANY calculations is | or & . Commented Sep 12, 2013 at 19:08 If the user of the application is a different person than the developer, then it is no problem. Commented Sep 12, 2013 at 19:11

i am new in java teacher ask me this question so i want some practical proof to know that it is possible how?

Commented Sep 12, 2013 at 19:11

5 Answers 5

I don't understand what you mean fully. If you mean an application that doesn't instantiate any non-standard classes, then yes of course, here:

public class MyApplication < public static void main(String[] args) < System.out.println("hello world"); >> 

If you mean an application in which we don't have any non-standard classes at all, then no: you need to have a main() method in some class somewhere.

answered Sep 12, 2013 at 19:08 129k 26 26 gold badges 243 243 silver badges 291 291 bronze badges no dear using only built in classes and variables(fields)/methods Commented Sep 12, 2013 at 19:12

You have no choice you must declare a class for your main. After that the example is exactly doing what you ask. It uses built in classes String and System, part of the standard JRE.

Commented Sep 12, 2013 at 19:19 yes by using only predefined classes any program pls tell me Commented Sep 12, 2013 at 19:37 @jayeshbsk5 In what way does the snippet in my answer not do this? Commented Sep 12, 2013 at 19:39

Well, yeah. All existing libraries either use built-in methods or use another library that does, or somewhere down the chain built in methods will be used.

All you would be doing is recreating functionality someone already built.

answered Sep 12, 2013 at 19:08 5,281 2 2 gold badges 21 21 silver badges 37 37 bronze badges yes i want that. but how i dont know pls tell me Commented Sep 12, 2013 at 19:13

"Any" application no.."an" application yes

answered Sep 12, 2013 at 19:08 2,754 4 4 gold badges 29 29 silver badges 38 38 bronze badges Outside of libraries that interact with the OS, like GUIs, then it's actually all possible. Commented Sep 12, 2013 at 19:09 which pls tell me practically Commented Sep 12, 2013 at 19:12

You will need to write the class that contains your main(), so strictly speaking, no. But apart from that, you can get quite a lot done with the standard JRE library.

answered Sep 12, 2013 at 19:08 55.7k 14 14 gold badges 79 79 silver badges 119 119 bronze badges but how i dont know pls tell me Commented Sep 12, 2013 at 19:14

not fully functional application only basic operation need to use in application without declaring user defined class (class should be predefined in java)

Commented Sep 12, 2013 at 19:41

JAVA is an object oriented language so in normal usage you would define classes. However, you can do pure functional programming in JAVA, without instantiating any user defined object. But every function must be contained in a class, so you will need to define at least a single class that holds your application logic.

answered Sep 12, 2013 at 19:20 5,924 1 1 gold badge 17 17 silver badges 32 32 bronze badges MyOnlyClassThatIDontInstatiate. this is built in class? reply Commented Sep 12, 2013 at 19:39

@jayeshbsk5 No, as I explained above, you have to define at least one class, because all code needs to be contained in a class. Java does not know the concept of code outside a class. If you want to write code, it has to be contained in a class. I named the class MyOnlyClassThatIDontInstantiate . All functions are declared static so they can run without instantiating the class. That means, I don't have to call new MyOnlyClassThatIDontInstantiate()