Three 'outputs' instead of one?
Just some practice, I think I do kind of realise that with this code I go there and back again (first identifying individual words, followed by"/type", and then adding the word plus "/type" again in an arrayList), but the thing is, for the input:
"the/AT dog/NN ate/VBN the/AT cat/NN"
I get:
the/AT-
the/AT-
the/AT-
dog/NN-
dog/NN-
dog/NN-
ate/VBN-
ate/VBN-
ate/VBN-
the/AT-
the/AT-
the/AT-
cat/NN-
cat/NN-
cat/NN-
And I can't understand why there's three and not one...
array = words.split(" ");
for (int i = 0; i < array.length; i++){
text = array;
ArrayList ray = new ArrayList();
ArrayList stevie = new ArrayList();
String [] anArray = text.split("/");
for (int j = 0; j < anArray.length; j++){
word = anArray[0];
type = anArray[1];
String wt = anArray[0] + "/" + anArray[1];
ray.add(wt);
charles = word + "-" + type;
for (int l = 0; l < ray.size(); l++){
String str = ray.get(l).toString() + "-";
textArea.append(str + newline);
What they both said, in spades... and also try to avoid "deeply nested" structures of all sorts.
If you can follow a-loop-within-a-loop-with-a-loop then you're smarter than me... I'm just smart enough to avoid having to be that smart, by splitting the job up into little tasks.
For instance: To process a cube (a 3D array) you could have a processCube(Thing[][][]) method which loops through each "matrix" (a 2D array) and just calls the processMatrix(Thing[][]) method... which in turn just calls processRow(Thing[])... which in turn (might) just call processThing(Thing)
Simple is good... most programmers habitually outsmart themselves when they're learning (I know I did)... You can never have too many methods, or indeed too many classes... except... [beware the double DAO pattern|http://www.zedshaw.com/essays/master_and_expert.html].
Edited by: corlettk on 26/02/2009 21:52 ~~ Clearer ~~ And less self-centric ;-)
Similar Messages
-
Arrow keys scroll three lines instead of one as of FF10, fix?
As of FF10, I can no longer scroll a single line in the browser and it is driving me nuts. Is there a way to go back to one line per arrow press scroll? Thanks!
You may have Switched ON '''Caret Browsing'''
* press '''F7''' (on Mac: '''fn + F7''') to Toggle on/Off '''Caret Browsing'''
Check and tell if its working.
Not related to your problem but some of your Firefox Plugins are out-dated
* Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
* '''When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)''' -
Every time I open up my Firefox browser, not only do I get my home page but I also get two more tabs. I also can't view things at some sites that I was able to before and with some of the facebook games, I can't access things like I could before. All of this started the same time. I've investigated and reinstalled things and nothing works. It's very annoying. Please help me, I am running out of ideas of how to fix this problem.
-> [[How to set the home page#w_restore-the-default-home-page|Restore the default home page]]
-> Now, [[How to set the home page#w_set-a-single-web-site-as-your-home-page|Set a single web site as your home page]]
Check and tell if its working. -
Mac Pro with two graphic card each one with two dvi output, can I extend deskop to three outputs?
MAC OS 10.7.4 3.2GHz Quad-Core Intel Xeon processors, 12GB of 800MHz DDR2 and 2 ATI Radeon HD 2600 XT 256MB (two dual-link DVI ports) . The problem is, I woul like to use one output as main and the three others as secondary or extended desktop but the system don't allow me use two diferent video cards this way.
-
How to use logger to send any output instead of the console?
How to use logger to send any output instead of the console?
How to use logger to send any output instead of the
console?There are three commonly used logger inferfaces, the log4j, the java.util.loging and the Commons logging (which works with either.)
You create a logger object, generally one for each class. Normally a private static variable points to it and it has a name equal to the FQN of the class.
e.g.
package org.widget;
public class MyClass {
private static Logger log = Logger.getLogger("org.widget.MyClass");That's the java.uitil.Logger formula.
Then there are method on the logger to call for various kinds of output. There' are different logging levels, priorities like SEVERE or DEBUG. When running the logs are configured to ignore messages of less than a set priority.
You can also pass an Exception or Error to the logger which will log the stack trace. -
Add three stored procs in one big proc and add exception handling
I have three proc's,
1. sp_staging
2. sp_upload
3. sp_process.
Now, I have to create a new proc as sp_daily which has the other three proc's in it in the same order.
if the first proc sp_staging fails, then the sp_daily proc should stop executing the other proc's which are in the order.
CREATE PROCEDURE sp_daily
AS
BEGIN TRY
EXEC sp_staging (already has EXCEPTION handling IN it)
GO
EXEC sp_upload (already has EXCEPTION handling IN it)
GO
EXEC sp_process (already has EXCEPTION handling IN it)
GO
END TRY
BEGIN CATCH
-- If any of the above proc's fail, the next proc's should not be executed
END CATCH
Something like this????Hi naveej,
Whether the Stored Procedure sp_daily stops executing if the first sp_staging fails depends on how you code. To give a better demonstration, I will show the scenario that sp_upload runs with error. Please see the below code.
--create the scenario
USE master;
IF db_id('TestDB') IS NULL
CREATE DATABASE TestDB;
USE TestDB;
IF OBJECT_ID('T1') IS NOT NULL
DROP TABLE T1;
GO
CREATE TABLE T1
procName varchar(99)
IF OBJECT_ID('sp_staging') IS NOT NULL
DROP PROCEDURE "sp_staging";
GO
CREATE PROCEDURE "sp_staging" @denominator FLOAT
AS
BEGIN TRY
DECLARE @quotient FLOAT;
SET @denominator=1/@denominator; -- when @denominator=0, error occurs
INSERT INTO T1 VALUES('sp_staging finished');
END TRY
BEGIN CATCH
END CATCH
GO
IF OBJECT_ID('sp_upload') IS NOT NULL
DROP PROCEDURE "sp_upload";
GO
CREATE PROCEDURE "sp_upload" @denominator FLOAT
AS
BEGIN TRY
DECLARE @quotient FLOAT;
SET @denominator=1/@denominator;
INSERT INTO T1 VALUES('sp_upload finished');
END TRY
BEGIN CATCH
DECLARE @ERRMSG VARCHAR(99);
SELECT @ERRMSG=ERROR_MESSAGE()+'sp_upload failed, process continues';
INSERT INTO T1 VALUES(@ERRMSG);
END CATCH
GO
IF OBJECT_ID('sp_process') IS NOT NULL
DROP PROCEDURE "sp_process";
GO
CREATE PROCEDURE "sp_process" @denominator FLOAT
AS
BEGIN TRY
DECLARE @quotient FLOAT;
SET @denominator=1/@denominator;
INSERT INTO T1 VALUES('sp_process finished');
END TRY
BEGIN CATCH
END CATCH
GO
IF OBJECT_ID('sp_daily') IS NOT NULL
DROP PROCEDURE "sp_daily";
GO
CREATE PROCEDURE "sp_daily" @p1Deno FLOAT,@p2Deno FLOAT,@p3Deno FLOAT
AS
BEGIN TRY
EXEC sp_staging @p1Deno;
EXEC sp_upload @p2Deno;
EXEC sp_process @p3Deno;
END TRY
BEGIN CATCH
INSERT INTO T1 SELECT ERROR_MESSAGE()+'error captured by sp_daily';
END CATCH
GO
--Test Example
TRUNCATE TABLE T1;
EXEC sp_daily 1,0,1;
SELECT * FROM T1;
We can judge from the rows in T1, sp_daily continued even when there came a error in sp_upload. The reason for the continuity is that the error which occurred in sp_upload was caught and handled by sp_upload itself. Sp_daily's CATCH block didn't capture
any error(we didnt see any row like "error captured by sp_daily") so sp_dailys continued running with no interruption.
Let’s make a little modification on the sp_upload. see the below code.
ALTER PROCEDURE "sp_upload" @denominator FLOAT
AS
BEGIN TRY
DECLARE @quotient FLOAT;
SET @denominator=1/@denominator;
INSERT INTO T1 VALUES('sp_upload');
END TRY
BEGIN CATCH
DECLARE @ERRMSG VARCHAR(99),@ErrSeverity INT;
SELECT @ERRMSG=ERROR_MESSAGE()+'sp_upload failed, process got terminated',@ErrSeverity=ERROR_SEVERITY();
RAISERROR(@ERRMSG ,@ErrSeverity,1);
END CATCH
GO
--Test Example
TRUNCATE TABLE T1;
EXEC sp_daily 1,0,1;
SELECT * FROM T1;
At this time, sp_daily got terminated when sp_upload encountered an error. Sp_upload didn’t handle the error, it threw the error instead. Then the CATCH block in sp_daily caught the error and interrupted sp_daily itself. If you don’t
need to handle the error which may occur inside of the inner called procedures, the TRY and CATCH block in the procedure which calls them would be enough to catch and handle the errors anywhere it occurs, just remove the blocks from the called ones.
ALTER PROCEDURE "sp_staging" @denominator FLOAT
AS
DECLARE @quotient FLOAT;
SET @denominator=1/@denominator;
INSERT INTO T1 VALUES('sp_staging finished');
GO
ALTER PROCEDURE "sp_upload" @denominator FLOAT
AS
DECLARE @quotient FLOAT;
SET @denominator=1/@denominator;
INSERT INTO T1 VALUES('sp_upload finished');
GO
ALTER PROCEDURE "sp_process" @denominator FLOAT
AS
DECLARE @quotient FLOAT;
SET @denominator=1/@denominator;
INSERT INTO T1 VALUES('sp_process finished');
GO
ALTER PROCEDURE "sp_daily" @p1Deno FLOAT,@p2Deno FLOAT,@p3Deno FLOAT
AS
BEGIN TRY
EXEC sp_staging @p1Deno;
EXEC sp_upload @p2Deno;
EXEC sp_process @p3Deno;
END TRY
BEGIN CATCH
INSERT INTO T1 SELECT ERROR_MESSAGE();
END CATCH
GO
--Test Example
TRUNCATE TABLE T1;
EXEC sp_daily 1,0,1;
SELECT * FROM T1;
As we can see from the above modification, sp_daily calls sp_staging, sp_upload, sp_process in order. Sp_staging runs fine so it finishes. When it comes to sp_upload, error gets captured so the execution terminates. Anyway if you hope that the 3
called procedures work atomically(it is a pretty common business requirement), which means unless all of the three finish otherwise no one finishes, the TRAN block would help. Please see the below code.
ALTER PROCEDURE "sp_daily" @p1Deno FLOAT,@p2Deno FLOAT,@p3Deno FLOAT
AS
BEGIN TRY
BEGIN TRAN
EXEC sp_staging @p1Deno;
EXEC sp_upload @p2Deno;
EXEC sp_process @p3Deno;
COMMIT TRAN;
END TRY
BEGIN CATCH
ROLLBACK TRAN;
INSERT INTO T1 SELECT ERROR_MESSAGE();
END CATCH
GO
--Test Example
TRUNCATE TABLE T1;
EXEC sp_daily 1,0,1;
SELECT * FROM T1;
If you have question, feel free to let me know.
Best Regards,
Eric Zhang -
i downloaded an album on itunes using my new itouch; but it's only allowing me to put three songs at any one time into the music app...how can i get it to just move them all in there?
hi philly, thanks for getting back to me, especially on such a busy day.
I don't think that's quite the issue though. I bought an album and it appears in 'my purchases' within the itunes app. Yet, in order to listen to the music, i must use the 'music' app and in this application, there are only three tracks displayed at any one time from my downloaded album.
I can 'download all' from the 'my purchases' section but that still doesn't help, it just keeps the last three tracks downloaded in the music app.
I have the 'icloud' enabled and wondered if it had anything to do with that.
i have successfully downloaded another full album totally into the music app, but this first album is causing me problems. -
How to setup three SharePoint sites on one server?
Hello,
How to setup three SharePoint sites on one server? I have three sites like:
http://site1
http://site2
http://site3
And need to have them running up on one server. I recall some changes need to be done to the host file, but not sure. Can you advise on what to change?
Thanks,
Paul
Paulyou need to make entries in DNS to get this done.
check here:http://spshare.blogspot.com/2012/05/how-to-create-host-header-web.html
nice blog with step by step explanation:
http://thuansoldier.net/?p=1323
Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog -
hello..i use firefox 4 beta 05..my question is..why when i open let's say 6 tabs..my windows show that i have 6 instancies of firefox instead of one like it does with firefox 3.6? thanks
maybe i am saying it wrong..when i press alt+tab there is only one firefox open..but in windows 7 in the taskbar..every tab open..appears as another window openIf you are referring to taskbar previews, you can turn them off by modifying a hidden preference.
# Type '''about:config''' into the location bar and press enter
# Accept the warning message that appears, you will be taken to a list of preferences
# In the filter box type '''previews'''
# Double-click on the preference browser.taskbar.previews.enable to change its value to '''false''' -
How do I combine three itune accounts into one? Then how do I set up three users for the one Itunes account on ONE Mac Pro Computer with one Itunes program? We are one family with 3 I-Phones, 2- I-Pads, 2- Lap tops and 3-I-Pods and would like to use one main computer to sync all our devices to.
"How do I combine three itune accounts into one? "
You cannot.
"Then how do I set up three users for the one Itunes account on ONE Mac Pro Computer with one Itunes program?"
You can copy all of the music to one computer and set up different users see:
Learn how to set up additional user accounts.
How to use multiple iPods, iPads, or iPhones with one computer -
How do I delete multiple items at once instead of one at a time?
How do I delete multiple items at once instead of one at a time? I have several duplicate items in my library and would like to delete the duplicates. Thanks!
You can select multiple items using shift to select a range and control to add or remove items from it.
Regarding duplciates, Apple's official advice is here... HT2905 - How to find and remove duplicate items in your iTunes library. It is a manual process and the article fails to explain some of the potential pitfalls.
Use Shift > View > Show Exact Duplicate Items to display duplicates as this is normally a more useful selection. You need to manually select all but one of each group of identical tracks to remove. Sorting the list by Date Added may make it easier to select the appropriate tracks, however this works best when performed immediately after the dupes have been created. If you have multiple entries in iTunes connected to the same file on the hard drive then don't send to the recycle bin. This can happen, for example, if you start iTunes with a disconnected external drive, then connect it, reimport from your media folder, then restart iTunes.
Use my DeDuper script if you're not sure, don't want to do it by hand, or want to preserve ratings, play counts and playlist membership. See this thread for background. Please take note of the warning to backup your library before deduping, whether you do so by hand or using my script, in case something goes wrong.
(If you don't see the menu bar press ALT to show it temporarily or CTRL+B to keep it displayed)
tt2 -
How can I find all exclamation marks in my iTunes without clicking on each song? Can they be deleted all at once instead of one song at a time?
Lost & Found
Create a playlist called Found, select everything in Music and drag it into the Found playlist (it may take some time to count the tracks that are to be dropped). Create a smart playlist called Lost matching All the rules Playlist is Music and Playlist is not Found. Your lost tracks will be in this playlist.
Optional: It depends a bit on why things aren't where iTunes expects to find them but if they are in sensible Artist & Album folders in some common location then my FindTracks script should be able to reconnect them to iTunes. FindTracks uses some fuzzy matching routines and searches for multiple potential locations. For more details see this thread. Once you have repaired the tracks that can be found you can drag the contents of the Lost playlist into Found which will update things.
Or, you can simply delete all the tracks in the Lost playlist with Ctrl-A to select them and then Shift-Delete to delete.
tt2 -
How can you delete all the e mail at one time instead of one at a time?
How can you delete all the e mail at one time instead of one at a time?
you'd have to do it from the computer,
-
Is there a way to "delete all" iMessages in OSx instead of one at a time?
Is there a way to "delete all" iMessages in OS 10 (Yosemite) instead of one at a time? Now the only way seems to select each one, wait for the little "X" to pop up, select that, hit return to confirm delete, then do it again, and again, and again...
MikeHi,
You can highlight a chat by the list in the left of the main window and then use the File Menu > Delete conversation
Using the x only dismisses the chat from view.
Individual iMessages can be deleted one at a time by clicking on a Bubble but not the text (you will see bubble and text change in colour slightly) and then the Backspace key.
It is not possible to Clear in any way all the chats/conversation in the left hand list.
8:51 pm Wednesday; April 22, 2015
iMac 2.5Ghz i5 2011 (Mavericks 10.9)
G4/1GhzDual MDD (Leopard 10.5.8)
MacBookPro 2Gb (Snow Leopard 10.6.8)
Mac OS X (10.6.8),
Couple of iPhones and an iPad -
Is there a way to restore photos from Drop box to my desktop iPhoto in a large batch instead of one at a time? I tried and a zip file was downloaded but won't open. Says file format not recognized. I see how to do it one at a time with the "download" button in Dropbox but that's so cumbersome for lots of photos.
Have you tried these avenues?
Contact us - Dropbox
Dropbox Help Center
Dropbox Forums
Submit a help request - Dropbox
OT
Maybe you are looking for
-
How do I get my contacts back? iOS 6 upgrade ate them
Updating to iOS 6 ate half my contacts! I backed my iPhone up before doing the upgrade.
-
Create Vendor manually by XK01
Dear Gurus , I am not able to create a Vendor with internal number range assignment. I have defined a vendor account group 8598 for services provider account group vendors and assigned a number range 85980001 to 85989999 to it with internal number
-
PDF links crashes Firefox. ThinApp unexpected error PID=10156
Whenever I click on a PDF web link, firefox crashes. I get this error: ThinApp has encountered an unexpected error. Click Abort to close the application, Retry to debug, or Continue to ignore the error. Support Info: PID=10156, new_Sections.cpp@274.
-
Has any one (or) can we run 11i and R12 in single AIX 5.3 OS
Hi, I have a requirement for running 11.5.10.2 and R12.1.3 in single AIX 5.3 OS. The only thing i doubt about is the pre-requisites like Java version, and other packages. Would be there be any conflict or version mismatch. Thanks
-
Downloading after deleting from creative cloud
I downloaded the trail version of adove flash professional cc about two months ago, i used it for a month then i deleted it from my mac, now i have purchased it and it will not let me download it because creative cloud says that i already have it. ho