Simple problem with a list initialization.
hello ! i have a class Contact and i would like to make a list of lists of Contact variables .. but when i try to run my code , it says "IndexOutOfBoundsException: Index: 0, Size: 0" . I know that every list of the list must be initialized .. but i don't know how .
here is the declaration of the List
static List<List<Contact>> lolContact=new ArrayList<List<Contact>>();and i know that i should do something like :
lolContact.get(0)=new ArrayList<Contact>();to initialize every list of the list but i don't know how . please help
badescuga wrote:
and i know that i should do something like :
lolContact.get(0)=new ArrayList<Contact>();
Couple of problems with that.
1. You can never do methodCall() = something in Java. The result of a method call is not an L-value.
2. You're trying to assign a ContactList to a Contact variable. Basically, you're trying to do
Contact c = new ArrayList<Contact>();3. Even if you changed it to
Contact c = lolContact.get(0);
c = new Contact();it would not put anything into the list. That would just copy the first reference in the list and stick it into variable c, so that both c and the first list item point to the same object (remember, the list contains references, not objects--no object or data structure ever contains an object in Java), and then assigns a completely different reference to c, forgetting about the one to the object pointed to by the list. It would not affect the list in any way.
4. You can't do get(0) until you've first put something into the list.
Similar Messages
-
Having problem with reading list in safari
i am having problem with reading list in safari some time it work sometimes gets hang....
Might be a cache issue ...
Open a Finder window. From the Finder menu bar click Go > Go to Folder
Type or copy paste the following:
~/Library/Caches/com.apple.Safari/Cache.db
Click Go then move the Cache.db file to the Trash.
Quit and relaunch Safari to test. -
Hi friends,
I have created one program with alv list, but i am unable to add one header and footer, also i have to add one logo to the program. Plese some one tell me a easy procedure to add a header, footer and also a logo. If you can show me one with example that would be very helpful.
This is my program, plz add the necessary parts.
*& Report Y_BOM2_ALV
REPORT y_bom2_alv LINE-SIZE 350 LINE-COUNT 350.
*& Include YINCLUDE1
TABLES : mast, stko, stpo.
TYPE-POOLS : slis.
DATA : BEGIN OF iall OCCURS 10,
matnr LIKE mast-matnr,
werks LIKE mast-werks,
stlan LIKE mast-stlan,
stlal LIKE mast-stlal,
stlst LIKE stko-stlst,
posnr LIKE stpo-posnr,
idnrk LIKE stpo-idnrk,
menge LIKE stpo-menge,
meins LIKE stpo-meins,
ausch LIKE stpo-ausch,
lgort LIKE stpo-lgort,
END OF iall.
DATA : i_repid LIKE sy-repid,
i_lines LIKE sy-tabix.
DATA : int_fcat TYPE slis_t_fieldcat_alv.
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE title1.
PARAMETER : p_werks LIKE mast-werks.
SELECT-OPTIONS : s_matnr FOR mast-matnr.
SELECTION-SCREEN END OF BLOCK a1.
INITIALIZATION.
title1(50) = ' Bill Of Material Input Screen '.
*& Include YINCLUDE2
START-OF-SELECTION.
SELECT mastmatnr mastwerks maststlan maststlal stko~stlst
stpoposnr stpoidnrk stpomenge stpomeins stpo~ausch
stpo~lgort INTO TABLE iall FROM stpo INNER JOIN stko ON
stpostlnr = stkostlnr INNER JOIN mast ON
stpostlnr = maststlnr WHERE mast~werks EQ
p_werks AND mast~matnr IN s_matnr.
IF sy-subrc <> 0 OR p_werks EQ ' ' OR s_matnr EQ ' '.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
titel = 'ERROR MESSAGE ( INPUT ERROR / WRONG INPUT ) '
textline1 = ' PLANT / MATERIAL Invalid or Empty '
textline2 = ' Plese enter plant no / material no again '
start_column = 20
start_row = 5.
EXIT.
ENDIF.
CLEAR i_lines.
DESCRIBE TABLE iall LINES i_lines.
IF i_lines LT 1.
WRITE: /
'No materials found.'.
EXIT.
ENDIF.
END-OF-SELECTION.
i_repid = sy-repid.
*& Include YINCLUDE3
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_repid
i_internal_tabname = 'IALL'
i_inclname = i_repid
CHANGING
ct_fieldcat = int_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
WRITE: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = i_repid
it_fieldcat = int_fcat
i_save = 'A'
TABLES
t_outtab = iall
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
ENDIF.Hi Tapodipta,
See below example and modify ur code according to ur requirement..
REPORT ZTEST_ALV_CHECK .
TYPE-POOLS: SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
L_LAYOUT type slis_layout_alv,
x_events type slis_alv_event,
it_events type SLIS_T_EVENT.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
SELECT VBELN
POSNR
FROM VBAP
UP TO 20 ROWS
INTO TABLE ITAB.
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
x_events-NAME = SLIS_EV_END_OF_PAGE.
x_events-FORM = 'END_OF_PAGE'.
APPEND x_events TO iT_EVENTS.
CLEAR x_events .
x_events-NAME = SLIS_EV_TOP_OF_PAGE.
x_events-FORM = 'TOP_OF_PAGE'.
APPEND x_events TO iT_EVENTS.
CLEAR x_events .
x_events-NAME = slis_ev_end_of_list.
x_events-FORM = 'END_OF_LIST'.
APPEND x_events TO iT_EVENTS.
CLEAR x_events .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = L_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
it_events = it_events
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FORM TOP_OF_PAGE.
* BREAK-POINT.
WRITE: / 'TOP_OF_PAGE'.
ENDFORM.
FORM END_OF_LIST.
* BREAK-POINT.
"here you can use this for footer
WRITE: / 'FOR FOOTER'.
ENDFORM.
FORM END_OF_PAGE.
* BREAK-POINT.
WRITE: / 'END_OF_PAGE'.
ENDFORM.
Go through the link as well..
Re: ALV Footer
Hope it will solve ur problem..
<b>Reward points if useful..</b>
Thanks & Regards
ilesh 24x7 -
Is there a way to fix ipod touch screen display problem with song list?
I was wondering if anybody has had this problem? I have an ipod touch 64gig 5th gen for probably about 2 years. I hardly use it because I have it as a back up ipod until primary one dies. This is the first time I came across this problem. Upon turning on device, the first artist/song list I choose displays correctly. Once I start choosing any other artist/song list afterwards, the display for the 1st artist/song list re-appears. If the song list is only a single song to 3-4 songs it will display correctly. Any other song list I choose that consist more than 5 songs, the first artist/song list re-appears on screen like the display is messed up.
For example: Upon turning on device, I choose Aaliyah with a list of 9 songs displaying.
Upon trying to select a different artist and song, for example I choose Nachtmar with a list of 20 songs.
The Aaliyah with the list of 9 songs re appears in place of the song list I am attempting to choose. The songs play and it works, but the display is incorrect. Why is it doing this? Does anybody have this problem? I have tried resetting and it has currently been updated. I have came across this problem just very recently a couple of days ago. I have had a couple of hard resets requiring to erase all data in the past and I don't want to go that way again because I have about 3,500 songs. I have never experience this problem before in the past. I just want it to display the current list of songs. It's inconvenient having to type in every song while playing in the car instead of being able to easily pick an individual song.I have this problem too and it drives me crazy. When I view my ipod, I don't want to see a list of the first 8 songs in my ipod library. I just want to see the current song playing. It's like the ipod display goes into some type of "sleep" mode while your music plays,and the display defaults to show the first few songs in your ipod touch library, even though none of those songs are currently being played. I have to take the time to either flip the ipod over a couple of times in order for that list to disappear just to see the current song playing.
This is an example of what I see on my display after the current song begins playing. These are the first songs in my ipod library. To get rid of this view, I have to either shake the ipod or flip it over a couple of times and the current song is now displayed, allowing you to see the current song, also allowing you access to the arrows to either fast forward or playback/reverse. On the display, the songs are in a grid or table format (unable to show that here).
Acoustic Soul
Aaliyah
Adventers on the Wheels
Adventures in Paradise
After Tonight
Will Downing -
A simple problem with sateful Session beans
Hi,
I have a really novice problem with stateful session bean in Java EE 5.
I have written a simple session bean which has a counter inside it and every time a client call this bean it must increment the count value and return it back.
I have also created a simple servlet to call this session bean.
Everything seemed fine I opened a firefox window and tried to load the page, the counter incremented from 1 to 3 for the 3 times that I reloaded the page then I opened an IE window (which I think is actually a new client) but the page counter started from 4 not 1 for the new client and it means that the new client has access to the old client session bean.
Am I missing anything here???
Isn�t it the way that a stateful session bean must react?
This is my stateful session bean source.
package test;
import javax.ejb.Stateful;
@Stateful
public class SecondSessionBean implements SecondSessionRemote
private int cnt;
/** Creates a new instance of SecondSessionBean */
public SecondSessionBean ()
cnt=1;
public int getCnt()
return cnt++;
And this is my simple client site servlet
package rezaServlets;
import java.io.*;
import java.net.*;
import javax.ejb.EJB;
import javax.servlet.*;
import javax.servlet.http.*;
import test.SecondSessionRemote;
public class main extends HttpServlet
@EJB
private SecondSessionRemote secondSessionBean;
protected void processRequest (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
response.setContentType ("text/html;charset=UTF-8");
PrintWriter out = response.getWriter ();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet main</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Our count is " + Integer.toString (secondSessionBean.getCnt ()) + "</h1>");
out.println("</body>");
out.println("</html>");
out.close ();
protected void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
processRequest (request, response);
protected void doPost (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
processRequest (request, response);
}You are injecting a reference to a stateful session bean to an instance variable in the servlet. This bean instance is shared by all servlet request, and that's why you are seeing this odd behavior.
You can use type-leve injection for the stateful bean, and then lookup the bean inside your request-processing method. You may also save this bean ref in HttpSession.
@EJB(name="ejb/foo", beanName="SecondBean", beanInterface="com.foo.foo.SecondBeanRemote")
public MyServlet extends HttpServlet {
ic.lookup("java:comp/env/ejb/foo");
} -
Problem with public folder initialization on exchange load generator 2010
hi,
we need to make some stress charge for a migration between 2010 and 2013. Before that we need to populate our exchange 2010 lab with full mailbox and public folders. So we tried Exchange load generator 2010 for this task ( initialization only).
Loadgen did well for the mailbox but we have some problems with the public folders. we have an empty public folder database and the user we run loadgen with has organization admin and public folder management right. the problem is that when we run this command
(for initializing public folder only, mailbox's done) :
loadgencmd.exe /p /c config.xml /add trace.log
IT create only one public folder with the user we run loadgen with, and 5-8 objects inside. We need that It create a public folder for each users it created before. Maybe we do not understand loadgen
correctly...I found my solution :
customize the <PublicStoreProfile> section in the configuration file as follows:
<PublicStoreProfile>
<MessageFiles />
<TopLevelFolderCount>1</TopLevelFolderCount>
<NonTopLevelFolderCount>1</NonTopLevelFolderCount>
<MinimumFolderDepth>1</MinimumFolderDepth>
<AverageFolderDepth>2</AverageFolderDepth>
<MaximumFolderDepth>3</MaximumFolderDepth>
<MinimumMessageCount>5</MinimumMessageCount>
<AverageMessageCount>10</AverageMessageCount>
<MaximumMessageCount>15</MaximumMessageCount>
<UseOrdinalFolderName>false</UseOrdinalFolderName>
</PublicStoreProfile>
Simply put differents values for each variables. -
Problem with contact list in email w/ 3.0
After upgrading to 3.0 I'm having a problem with the "To" in emails. I start typing in a name in the "To" field and it does not bring up matching entries in my contact list (it used to do so with the previous version SW).
I have to try to send the email at which time an error message comes up. I have to cancel the send, delete the name in the "To" field and type the name in again. The second time it brings up the contact list and eveything works fine.
Anyone else having this problem?Jackson_Bill wrote:
What IDE are you using and what platform?Read first.
Moh Bob wrote:
I'm using J2ME platform SDK 3.0
db -
Simple problem with transitions
Hi everyone
I am having a small bit of a problem with transitions....
When I drag a clip from the viewer over the canvas to get the menu bar pop up, and select insert with transition ( cross dissolve ) it puts in a transition but its very short and too fast and when i select it and try to make adjustments it doesn't seem to let me make any changes to the cross dissolve.
I wander what i am doing wrong?
Many thanks TimHi
Just as David Harbsmeier indicates. Handles
Transitions are handled differently in iMovie resp FinalCut.
• iMovie - material that builds the transition is taken from the videoclips = the total length remains same
• FinalCut (as pro- works) . You have to set of a piece of material in each end of the video clips.
This is called In- resp. Out-points. The remaining parts are called Handles
Transitions here are using material from these = Total lenght of movie increase
per transition.
I find books/DVDs by Tom Wolsky - Very valubale - Enjoyed them very much.
• Final Cut Express 4
• Final Cut Pro 6 - DVD course (now probably version 7)
Yours Bengt W -
hi!
i've a problem with user input in my application:
Code:
BufferedReader F_reader = new BufferedReader (new InputStreamReader(System.in));
Fs_line = F_reader.readLine();
My problem is that i've to press the return key for two times, before the JDK returns the line! Does anybody know a better solution with JDK 1.4.2?
thanks for help
mikeit was a mistake of our own implementation! code ist correct! any circumstances are our eval!
thanks mike -
i have make a database with linked list for a School student counselor.
The to be store is
student name, ID, Counseling Date, Progress
In there there will be record for a student and the Date and progress has to be stored for 4-weeks as the counseling is on weekly basis. These data items will be multivalued(what u say in Databases) how i can store this repetitive data in linked list for one student.By capsulating the data in objects and adding the objects to a linked list.
-
Problems with Smart List in Forms.
Hi,
I set Smart List in my Account Dimension.
In HP Documentation (9.2 and 9.3.1) I read that is posible to allow or not allow a user using Smart List for a specific member of account through a form option.
I already used this option in HP 9.2, but in 9.3.1 it do not exist this option in dataform, even so in 9.3.1 documentation says that it's posible.
I wanna Know if someone have used this option in 9.3.1.
I have been thinking in re install Planning or duplicate member that I need use sometimes with Smart List and sometimes writing a number.
Any idea???
Thankstbian wrote:
John,
That is true, it states that there is an option to turn Smart List off and on for any data form. It does state within the admin guides but I don't see the option when I edit the data forms.
Am I missing something?
Best Regards,
Tammy Bian CarlileI think the documentation is saying you can either have all the forms displaying smart lists or the other choice is not to have them, this is defined by using the evaluation order.
Cheers
John
http://john-goodwin.blogspot.com/ -
Probably simple problem with while loops
I was programming something for a CS class and came across a problem I can't explain with while loops. The condition for the loop is true, but the loop doesn't continue; it terminates after executing once. The actual program was bigger than this, but I isolated my problem to a short loop:
import java.util.Scanner;
public class ok {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String antlol = "p";
while(antlol == "p" || antlol == "P"){
System.out.println("write a P so we can get this over with");
antlol = scan.nextLine();
//it terminates after this, even if I type "P", which should make the while condition true.
}Thanks, that worked.
I think my real problem with this program was my CS
teacher, who never covered how to compare strings,Here's something important.
This isn't just about comparing Strings. This applies to comparing ANY objects. When you use == that compares to see if two references refer to the same instance. equals compares objects for equality in the sense that equality means they have equal "content" as it were. -
Problem with External List Management; Business Partner Type
Hello experts;
I created a mapping format for importing a simple notepad file. In the ELM i see all my fields populated correctly. Once i start the importing process it goes smoothly with no mistakes at all (green lights). The bp is actually imported and i can see it in the BP transaction with most of the fields correctly imported BUT the business partner type (PERS_PERS_BPKIND in ELM). For this field i have a Constant Assignment which is always HH and because of that i don't have it in my notepad file but i pass the value directly from ELM constant assignement=HH. Unfortunately this value is not copied. Any idea? Am i doing something wrong or i'm loosing some steps in between?
Thank you very muchHello,
the issue is most probably related to missing authorizations. As you know the processing in external list management happens in the background using WF-BATCH user.
Please check the following notes:
708557 - 'ELM: Troubleshooting' point 1.
https://service.sap.com/sap/support/notes/708557
1912414 - ELM upload: Error in the map data-step
https://service.sap.com/sap/support/notes/1912414
1664498 - External List will not execute
https://service.sap.com/sap/support/notes/1664498
The information provided in the notes should help to solve the issue.
best regards,
Johannes -
Problem with the List/Album List/Cover Flow/Grid view buttons
Is anyone else having this problem?
I have each playlist/media in different views. I have my music in List view, my podcasts, TV shows, and certain playlists in Album List view, and my movies and music videos in grid view. But now, any view that I select makes it the same for each playlist/media and I have to manually change it everytime I go to one of those lists. I figure this is a glitch with 10.5.3. Anyone else experiencing this?I'm also having that problem.
It seemed to happen after iTunes 10.5 updates.
I like my music in album list view and my apps in grid form. However, now it's just one view for all lists. Any fixes for this or is this a bug that needs to be ironed out by Apple? -
RH8 for HTML: Problem with Multilevel List in published topic(s)
I have discovered that working with the multilevel list and reapplying it (changing a level 2 to a level 1, for example) inserts numerous <span style margin> tags that don't show up in RH design view nor in an IE view of the published content, but the published help renders badly in Firefox (like a "justified" paragraph style that inserts broad spacing between words).
The bad thing is that broad spacing is added to a command where no spaces should be, which looks fine in IE, but renders like this in Firefox:
sqlplus XBRLDB/[email protected]:1521/ubmatrix
@C:\xbrl_database\database\Oracle\ verify_registration _v1_0 _1 .sql
The "source" for published content looks like this:
<p class="CodeSample" style="margin-left: 24px;">sqlplus XBRLDB/[email protected]:1521/ubmatrix
@C:\xbrl_database\database\Oracle\<span style="margin-left: 40px;">verify_registration</span>
<span style="margin-left: 40px;">_v1_0</span><span style="margin-left: 40px;">_1</span>
<span style="margin-left: 40px;">.sql</span></p>
How do I prevent the <span> tags from getting added to the RH project files? How do I remove them using the RH interface?
Why are they getting added in such wierd places?
PS: I have kept the paragraph style Numlist (which is how I define numbered procedures). I just apply the multilevel list to paragraphs tagged with this style. It's been working OK, except for the newly discovered problem above.
I'm using Verdana family and the numbers look good. I've only looked at the published HTML which looks like this: I
<p class="Numlist">1<span style='font:6.0pt "Times New Roman"'><font size="1" style="font-size:6pt;"> </font></span>Do this</p>
looks like this in a broser view:
1 Do this
Is this the 'expected' HTML code for numbered procedures (all this to precede a paragraph with a number), or is there a more efficient way to render numbered/mutilevel lists?Hi there
I just created a small video that may be helpful for this.
Cheers... Rick
Helpful and Handy Links
RoboHelp Wish Form/Bug Reporting Form
Begin learning RoboHelp HTML 7 or 8 within the day - $24.95!
Adobe Certified RoboHelp HTML Training
SorcerStone Blog
RoboHelp eBooks
Maybe you are looking for
-
Why is my itunes card not activated properly
what to do if my itunes card isn't activated properly?
-
Hi, I am a newbie when it comes to video editing. That said, I am very interested in learning as much about the editing process as I can. I have used iMovie for a while and I feel constrained - I feel like it is oversimplifying things to the point wh
-
Synchronization of past Outlook Calendar entries with Blackberry Q10
Is there no option to include the synchronization of past calendar entries from my Outllok Calendar? All what I found on Blackberry Link is "Import contacts/ Calendar". However, it seems that the synchronization applies only to future Outlook Calenda
-
Portal Logoff delaying.
Dear All, I'm facing the problem like while click on logoff, it will take time to logoff. My system is running on EP7.01 SP3. Please reply back how to resolve this. Really appriciated your inputs. Thanks and Regards, Mahee.
-
I bought a new laptop and downloaded itunes.I tried to download all the tunes i have on my account but it sats i have to authorize my computer,how do i do that?