473,378 Members | 1,457 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,378 software developers and data experts.

java array type object of

Array type object of a class is declared like abc a[10]=new abc(); but how to call methods
Aug 5 '07 #1
4 1794
JosAH
11,448 Expert 8TB
Array type object of a class is declared like abc a[10]=new abc(); but how to call methods
That is not a valid initialization, nor assignment. The 'new abc()' expression
results in a new object of type abc, not in an array type. btw, an array doesn't
have methods either so you can't invoke them.

Or maybe I misunderstood your question completely in which case you have
to elaborate or rephrase a bit.

kind regards,

Jos
Aug 5 '07 #2
That is not a valid initialization, nor assignment. The 'new abc()' expression
results in a new object of type abc, not in an array type. btw, an array doesn't
have methods either so you can't invoke them.

Or maybe I misunderstood your question completely in which case you have
to elaborate or rephrase a bit.

kind regards,

Jos
i think it should be like
abc a[]=new abc[10]; is it correct if yes then how to invoke a method
Aug 5 '07 #3
i think it should be like
abc a[]=new abc[10]; is it correct if yes then how to invoke a method
Aug 5 '07 #4
JosAH
11,448 Expert 8TB
i think it should be like
abc a[]=new abc[10]; is it correct if yes then how to invoke a method
Yes, that is correct. That initialization sets up an array with ten reference to an
abc object each. Note that there are no abc objects yet, the references don't
'point' at such an object yet. You have to populate the array yourself as in:

Expand|Select|Wrap|Line Numbers
  1. abc[] a= new abc[10]; // create a new array
  2. for (int i= 0; i< a.length; i++) // populate the array
  3.    a[i]= new abc();
  4.  
As I wrote above: you can't invoke methods on an array; you can invoke methods
on an element of an array of course:

Expand|Select|Wrap|Line Numbers
  1. a[3].foo(); // assuming foo() is a method of class abc
  2.  
kind regards,

Jos
Aug 5 '07 #5

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

Similar topics

73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
0
by: umhlali | last post by:
I get the following exception when my VB.NET app calls a Java web service that returns an array of objects. The same call works for a single object though. So looks like there is no problem...
1
by: Vaibhav Modak | last post by:
Hi All, I have a Web Service written in Java (Web Logic) and I am trying to call it in my ASP. NET client. I am facing a problem while getting the data from the Web Service Method. My Web...
2
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects"...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
5
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is...
0
by: r035198x | last post by:
Inheritance We have already covered one important concept of object-oriented programming, namely encapsulation, in the previous article. These articles are not articles on object oriented...
0
by: anuptosh | last post by:
Hi, I have been trying to run the below example to get a Oracle Array as an output from a Java code. This is an example I have found on the web. But, the expected result is that the code should...
2
by: yeshello54 | last post by:
so here is my problem...in a contact manager i am trying to complete i have ran into an error..we have lots of code because we have some from class which we can use...anyways i keep getting an error...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
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...

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.