473,385 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Is there any way to instantiate the System class?

Siddarth777
hi, am a newbie java programmer

as we know that when we want to print anything on console
System.out.println is used

but i want to instantiate the system class such that i can write the code as


System.obj1.println("hello world")

is there any way to do that

i wrote a sample code but it is not working
Expand|Select|Wrap|Line Numbers
  1. class helloworld
  2. {
  3.    System obj1=new System();
  4.    System.obj1.println("hello world");
  5. }
  6.  
but i am getting an error


The constructor System() is not visible
obj1 cannot be resolved or is not a field

please help, if there is any way to do that please tell me

thanks in advance
siddarth
Sep 4 '11 #1
3 1681
whodgson
542 512MB
You need to read-up on C++ classes. If you do not use an access specifier (public:,private: or protected:) data and methods are private by default and cannot be accessed directly.
BTW a class ends with a ';' e.g,:'};'
Sep 5 '11 #2
johny10151981
1,059 1GB
Besides you have defined like this
System obj1=new System();

now you have a object name obj1
Now if you want to access method(that is available) you will have to do like below:
obje.println("Hello world");

if println is a static function then you do not need to define the object. all you need to do is

System.println("Hello world");
Sep 6 '11 #3
johny10151981

thanks a lot for your reply but no luck
when i do as you say
a new error message pops up, saying
UNRESOLVED COMPILER ERROR

i am unable to understand where i went wrong
Sep 25 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ernesto | last post by:
Hi everybody: I have the following implementations: class A { public: virtual int GetValue() = 0; };
3
by: Alex Munk | last post by:
What I really want to do is something like this: Main { string classToInstantiate; if (something) classToInstantiate = "class1"; if (something) classToInstantiate = "class2";...
7
by: Simon Bond | last post by:
In C# we can go: <foo.cs> // Create a serializable class public class Foo : ISerializable { public void GetObjectData(SerializationInfo info, StreamingContext context) {};
1
by: Andreas Poller | last post by:
Hello, I have the following problem: I have a class deriving from ICustomTypeDescriptor: public __gc class TPropertyBag : public ICustomTypeDescriptor { private: ...
0
by: Primoz Gustincic | last post by:
I'm explicitly implementing an interface defined in assembly A. public __gc __interface IPop { Void GetPop(); }; public __abstract __gc class CPOP : public IPop { private:
1
by: Dean Slindee | last post by:
If a string variable contains a value that is the name of a class, is there any way to instantiate the class from the contents? Example: Dim strClassName as String = "Foo" Dim cls as New...
5
by: John | last post by:
Hi, is it possible to instantiate a class with a variable. example class foo: def method(self): pass x='foo'
1
by: learning | last post by:
Hi how can I instaltiate a class and call its method. the class has non default constructor. all examples i see only with class of defatul constructor. I am trying to pull the unit test out from...
1
by: ayan4u | last post by:
is it possible to send messages from system class such as "edit" to an application local class.... the situation is that i am in system class which is registered(by the system) for a child...
1
by: jainchar | last post by:
hello i m in trouble that my project is in vc++ with mfc.my program giving the error that error c2259:"CException" cannot instantiate abstract class. when i remove this error then my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
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...
0
by: emmanuelkatto | last post by:
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
0
BarryA
by: BarryA | last post by:
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...
1
by: Sonnysonu | last post by:
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.