Java coding Basics

Source: Internet
Author: User

If you want to write anything, consider it a learning note ~ Will be added later

All basic types of non-byte types can be converted to strings using the String. valueOf () method.
The equals method is required for comparison of non-basic types.
Obtain the parameter value for form submission.
1: String name = request.getParameter(Name);

Obtain the array value of Form submission
1: String[] nameList = request.getParameterValues(ListName);

Pass parameters to the page
1: request.setAttribute(var,value);

Session operation
1: session.setAttribute(var,value);
2:
session.getAttribute(var);
3:
session.removeAttribute(var);


Splits a string into arrays.
1: String[] col= MyStr.split(,);

Determine the length of the array
1: MyList.length;

Converts a string to an integer.
1: Integer.parseInt(Str);

Output pass value on JSP page
1:<Bean:Write name=ObjProperty=Id/>// An attribute of an object
2:
<Bean:Write name=Name/>


Map Operation Method
1: Map condition= new HashMap();
2:
condition.put(name, value);
3:
condition.get(name);


Date formatting
1:Date date= NewDate();
2:
SimpleDateFormat df= NewSimpleDateFormat(Yyyy-MM-dd);
3:
String today=Df.Format(Date);// Convert the date type to a string
4:
Date day=Df.Parse(2005-08-09);


Dynamic string method StringBuffer buffer = new StringBuffer (100 );
The following two items are relatively advanced.
Date Subtraction Method
1: import java.util.*;
2:
public class DateSubtraction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.