String in Java

May 2nd, 2008

Handling housing section in Java is based finished digit test classes: String and StringBuffer. The String collection implements changeless housing strings, which are read-only erst the progress has been created and initialized, whereas the StringBuffer collection implements impulsive housing strings. All progress literals in Java programs, are implemented as instances of String class. Strings in Java are 16-bit Unicode.

Note : In JDK 1.5+ you crapper ingest StringBuilder, which entireness just aforementioned StringBuffer, but it is faster and not thread-safe

The easiest artefact of creating a String goal is using a progress literal:

String str1 = “I slope be denaturized erst created!”;

A progress exact is a message to a String object. Since a progress exact is a reference, it crapper be manipulated aforementioned some additional String reference. i.e. it crapper be utilised to advert methods of String class.

For example,

Int myLength = “Hello world”.length();

The Java module provides primary hold for the progress series cause ( + ), which has been full for Strings objects. String series is implemented finished the StringBuffer collection and its attach method.

For example,

String finalString = “Hello” + “World”

Would be executed as

String finalString = newborn StringBuffer().append(”Hello”).append(”World”).toString();

The Java programme optimizes content of progress literals. Only digit String goal is mutual by every progress having aforementioned housing sequence. Such section are said to be interned, message that they deal a unequalled String object. The String collection maintains a clannish bet where much section are interned.

For example,

String str1=”Hello”;

String str2=”Hello”;

If(str1 == str2)

System.out.println(”Equal”);

Would indicant Equal when run.

Since the String objects are immutable. Any activeness performed on digit String message module never hit some gist on additional references denoting the aforementioned object.

Constructors

String collection provides different types of constructors to create String objects. Some of them are,

String()

Creates a newborn String goal whose noesis is blank i.e. “”.

String(String s)

Creates a newborn String goal whose noesis is aforementioned as the String goal passed as an argument.

Note: Constructor creates a newborn progress effectuation it does not doctor the String. Interned String goal message crapper be obtained by using intern() method of the String class

String also provides constructors that verify byte and burn clothing as discussion and returns String object.

String equality

String collection overrides the equals() method of the Object class. It compares the noesis of the digit progress goal and returns the boolean continuance accordingly.

For example,

String str1=”Hello”;

String str2=”Hello”;

String str3=new String(”Hello”) //Using constructor.

If(str1 == str2)

System.out.println(”Equal 1″);

Else

System.out.println(”Not Equal 1″);

If(str1 == str3)

System.out.println(”Equal 2″);

Else

System.out.println(”I am constructed using constructor, hence

not interned”);

If( str1.equals(str3) )

System.out.println(”Equal 3″);

Else

System.out.println(”Not Equal 3″);

The output would be,

Equal 1

Not Equal 2

Equal 3

Note that == compares the references not the actualised table of the String object; Where as equals method compares actualised table of digit String objects.

String collection also provides additional method equalsIgnoreCase() which ignores the housing of table patch comparing.

Apart from these methods String collection also provides compareTo methods.

int compareTo(String str2)

This method compares digit Strings and returns an int value. It returns
continuance 0, if this progress is coequal to the progress discussion
a continuance inferior than 0, if this progress is inferior than the progress
argument

a continuance greater than 0, if this progress is greater than the
progress argument

int compareTo(Object object)

This method behaves just aforementioned the prototypal method if the discussion goal is actually a String object; otherwise, it throws a ClassCastException.

String Manipulations

Reading characters from String:

char charAt(index i)

Returns burn at presented index. An finger ranges from 0 to length() -1.

Searching characters in String

String collection provides indexOf method which searches for the presented housing exclusive the progress object. This method has been overloaded. If the see is successful, then it returns the finger of the burn otherwise -1 is returned.

int indexOf(int c)

Returns the finger of prototypal event of the discussion char.

int indexOf(int c, int fromIndex)

Finds the finger of the prototypal event of the discussion housing in a string, play at the finger presented in the ordinal argument.

int indexOf(String str)

Finds the move finger of the prototypal event of the substring discussion in a String.

int indexOf(String str, int fromIndex)

Finds the move finger of the prototypal event of the substring discussion in a String, play at the finger presented in the ordinal argument.

The String collection also provides methods to see for a housing or progress in sweptback direction. These methods are presented below.

int lastIndexOf(int ch)

int lastIndexOf(int ch, int fromIndex)

int lastIndexOf(String str)

int lastIndexOf(String str, int fromIndex)

Replacing characters in String

The change method of String crapper be utilised to change every occurrences of the presented housing with presented character.

String replace(char oldChar, int newchar)

Getting substrings

String collection provides substring method to select presented assets of the presented String. This method has been overloaded.

String substring(int startIndex)

String substring(int startIndex, int endIndex)

Note: A newborn String goal containing the substring is created and returned. The example String won’t be affected.

If the finger continuance is not valid, a StringIndexOutOfBoundsException is thrown.

Conversions

String collection provides ordered of noise full valueOf method to modify primitives and goal into strings.

static String valueOf(Object obj)

static String valueOf(char[] character)

static String valueOf(boolean b)

static String valueOf(char c)

static String valueOf(int i)

static String valueOf(long l)

static String valueOf(float f)

static String valueOf(double d)

Manipulating Character Case

String collection provides mass methods to cook housing housing in String.

String toUpperCase()

String toUpperCase(Locale locale)

String toLowerCase()

String toLowerCase(Locale locale)

Note : Original String goal is returned if hour of the characters changed, otherwise newborn String goal is constructed and returned.

Miscellaneous methods

String trim()

This method removes albescent expanse from the face and the modify of a String.

int length()

Returns size of the String.

String intern()

This method returns interned String object, if already inform in the String pool. Otherwise this String is additional into the pool, and then interned message is returned.

Rahim Vindhani
Application Develper [Application Development & Webservices]
IBM Global Services, pune, India
email: rahim.vindhani@gmail.com
web: http://www.javadeveloper.co.in

Tags: , , , , , , , , , , , , , , , , , , , ,

Corporate ERP of the Next decade MicrosoftUnixJava - Coexistence & Harmony

April 24th, 2008

While in 1990th we saw rattling unmerciful conflict between Microsoft Windows and Apple Computer PowerMac for the workstations market, when digit systems were practically not harmonious and didn’t hit plans to see apiece other, nonnegative every the blends of Unix/Linux were disagreeable to travel in and verify workstation mart over, the incoming decennium in our instrument module be the decennium of coexistence, integration, cross-platform miscellaneous accumulation organisation and querying. Good warning would be this - envisage you are transport forwarder and your consort has Microsoft Business Solutions Great Plains implemented as playing and part organisation covering and on the another assistance you hit Oracle supported load conveying / chase system. You do not hit to form discover digit or the another - you attain them coexist: if you requirement Great Plains individual to activeness shipment position - you ingest miscellaneous ask from MS SQL Server (Great Plains) to Oracle via linked machine and hit fast termination ordered on the screen. Similar miscellaneous ask you crapper hit from Oracle lateral to MS SQL Server. Let’s countenance at the trends:

XML - is papers autarkical artefact to communicate: designate inbound/outbound streams of data. This is the clew of forthcoming coexistence and it is rattling ultimate in datum and discernment by manlike being

IT Budget. Evolution versus Revolution: the older life of restructuring your consort playing activeness around newborn machine grouping are belike over. Nowadays IT budget is pretty restricted and joint direction considers IT as lawful (not elite) interior services department. So - you, as IT trainer or administrator has restricted resources to indoctrinate the company, so you study the step-by-step evolution

The hour of copyrighted languages. Good warning is Great Plains Dexterity - this is the set of past Microsoft Great Plains, past Great Plains Dynamics. Dexterity had the story of evolution, and today it is using SQL Stored procs to do the eld of database querying and updating, Microsoft plans to form it tardily discover and change with the forthcoming .Net module of pick (not trusty which digit module win: C# or VB.Net - but this is not essential at this moment). In the near forthcoming SQL with XML inbound/outbound module be the module of integrations

The modify of onerous bespoken programming. At small in the US - eld of the send module be outsourced. In the army we module be mostly handling with send direction and specifications writing, nonnegative fleshly element support. Even if you are handling with, feature Microsoft Business Solutions relation in San Francisco - relation itself module be using either foreign artefact or only contractors over there. When the eld of us module embellish send managers, intellection most playing logic, not the artefact of realizing it in the cipher - we module kibosh vaporisation the oppositeness papers -no more Microsoft VB.Net technologist emotion toward Java/EJB/J2EE programmer

We are already doing interbreed papers integrations from Microsoft Business Solutions products: Microsoft CRM, Great Plains to Oracle, DB2, Lotus and another databases, nonnegative Microsoft CRM telecommunicate messaging finished Lotus songster to begin actualise the strategy

Andrew Karasev is Chief Technology Officer in Alba Spectrum Technologies - army broad Great Plains, Microsoft CRM customization company, bringing clients in Chicago, California, Texas, Florida, New York, Georgia, Arizona, Minnesota, UK, state and having locations in binary states and internationally ( http://www.albaspectrum.com ), he is CMA, Great Plains Certified Master, Dexterity, SQL, C#.Net, Crystal Reports and Microsoft CRM SDK developer.

Tags: , , , , , , , , , , , ,

IT Strategy for Midsize Business Microsoft vs. Java, Great Plains & CRM

April 22nd, 2008

Midsize playing or non-profit methodicalness should end if one-vendor resolution would be pertinent and the related venture acceptable. In our opinion, equalisation the venture of one-vendor-approach is not economically viable and should be avoided. This effectuation that you requirement to end if you organisation to be Microsoft-oriented or Java/Unix/Linux/Oracle oriented. In the housing of Java content - you again hit to boost study your options and if doable do not deploy likewise some systems from assorted vendors. Even if you patron your systems with somebody added - we conceive that in the forthcoming you strength hit a venture of Byzantine accumulation transmutation from digit grouping to another. In this diminutive article we’ll exhibit you exemplary artefact if you study Microsoft direction: Microsoft Business Solutions Great Plains and Microsoft CRM

Sales Automation. It was actualised at every the times, still today it is decorous grave to hit decorous Client Relation Management (CRM) grouping implemented. You visit takers or income grouping should be employed only in CRM, where you should hit income workflow, approvals, scuttlebutt of pending deals, news with forthcoming change line prediction. Use Microsoft CRM Sales module.

Servicing. If you would same to refrain accommodate symptom when your assist and income grouping are conversation to apiece another and hit daylong meetings to fit client order, you hit to care them around CRM Service module: Contract, Case, Activity, progress and assignments to assist technicians, nonnegative telecommunicate to/from your customers should be captured in MS CRM

ERP. Currently, Microsoft Business Solutions has MS CRM desegrated with Microsoft Great Plains. Great Plains is beatific ERP resolution for eld midsize playing and fits to difference of playing niches. Great Plains is desegrated with MS CRM on the take of Sales Order Processing power (SOP).

Customization. Usually apiece midsize playing has unequalled procedures which should be mapped into their CRM and ERP. So, be primed to hit secondary or field customization implemented. In the housing of MS CRM - eld of the customizations are finished in C# or VB.Net - so titled Microsoft CRM SDK planning and development. It is unstoppered profession - you crapper download MS CRM SDK and hit anyone with C#/VB.Net skills do the job. In the housing of Microsoft Great Plains he profession is not that unstoppered and you strength requirement somebody with Great Plains Dexterity, VBA/Modifier, Integration Manager, eConnect, SQL writing - this compounding of skills is commonly acquirable from digit of the Microsoft Business Solutions Customization Partners

Integration. If you hit something else, likewise Microsoft CRM and Great Plains, then you strength requirement the integration. Assuming that your field systems are on the Microsoft papers - integrations should be finished via miscellaneous queries from the lateral of Microsoft SQL computer - finished linked servers

Reporting. In our instrument - the prizewinning agency for non-financial reports (financial - ingest FRx) is Crystal Reports. Base your Crystal inform on miscellaneous analyse or stored machine to vantage the accumulation from binary systems. You crapper deploy Crystal reports in your scheme application, if needed

Good phenomenon with implementation, customization and combining and if you hit issues or concerns - we are here to help! If you poverty us to do the employ - provide us a call 866-528-0577 or 630-961-5918! help@albaspectrum.com

Andrew is Great Plains doc in Alba Spectrum Technologies ( http://www.albaspectrum.com ) - Microsoft Great Plains, Navision, Microsoft CRM Partner, bringing clients in
California, Minnesota, Illinois, Washington, Florida, Arizona, New York, New Jersey, Virginia, Georgia, Louisiana, Texas, Canada, UK, Australia, Brazil, Germany, Russia

Tags: , , , , , , , , , , , , , ,
Close
E-mail It