One : newly build Class class , Name it :Common

1.  Write public static Public static methods ;  2.  Direct use   Common. Method name You can call it directly .

for example : Write a method to get the current week .

/**
     * Use user format to extract strings
     * @param strDate week
     * @param pattern Date format
     * @return getWeek(new Date())
     */
    public static String getWeek(Date date){
        String[] weeks = {" Sunday "," Monday "," Tuesday "," Wednesday "," Thursday "," Friday "," Saturday "};
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if(week_index<0){
            week_index = 0;
        }
        return weeks[week_index];
    }

Two : Write a console output , See if the method is correct .

3、 ... and 、 use Debug Debugging method .

1. Through the transformation of methods ,week_index Can be converted into : The number

2. week_index  The return value of is : The current date is Sunday

Java How to write Common More related articles on direct call

  1. 【ZooKeeper series 】2. use Java Realization ZooKeeper API Call to

    reminder : Here I make a small request again , I hope you can get used to reading official documents , Although the documents are in English, they are easy to use , Basically can understand the meaning of the document . I believe we all know that it is better to teach fish than to teach fish , I also hope to pass this ZooKeepe ...

  2. paip.java c# .net php python call c++ c dll so windows api summary

    paip.java c# .net  php python call c++ c dll so windows api summary author Attilax  Elon ,  EMAIL:[email protected] Come on ...

  3. How to make Java and C++ Interfaces call each other :JNI Use guide

    How to make Java and C++ Interfaces call each other :JNI Use guide from :http://cn.cocos2d-x.org/article/index?type=cocos2d-x&url=/doc/cocos ...

  4. Free hand use Java To write a Web Server and framework &lt; Chapter two :Request and Response&gt;

    Free hand use Java To write a Web Server and framework < Chapter one :NIO piece > Connected to a , When it comes to accepting a request , The next step is to parse the request build Request object , And how to create Response Object returns . If there are many mistakes, please point out . Omit ...

  5. build rtmp Live streaming service 2: Use java Realization ffmpeg Command interface calls ( use java perform ffmpeg command )

    Welcome to join the discussion group Group number :371249677 ( Click here to join the group ) One . Environment building 1. install ffmpeg Download the ffmpeg Installation package , Personal adoption windows Platform development , So it's installed windo ...

  6. Java WebService Interface generation and invocation Graphic, &gt;【 turn 】【 To be adjusted 】

    webservice brief introduction : Web Service technology , It can make different applications run on different machines without the aid of additional . Specialized third-party software or hardware , You can exchange data or integrate with each other . basis Web Service Between the application of specification implementation ...

  7. Java Use OkHttps Tool classes call external interfaces

    Preface Now the company's business is no longer a simple business processing operation such as adding, deleting, modifying and querying , It is to interact with other systems through various joint debugging interfaces , Then we need to be backstage java External interface call in , In this paper OkHttps Tool class docking wechat interface ...

  8. Java A preliminary study on the overlap

    Java overwrite The main feature of inheritance is that subclasses can extend their functions according to the existing functions of their parents , However, when defining properties or methods in subclasses, it is possible to define properties and methods with the same name as the parent class , In this case it is called :“ overwrite ”. Method override :[ Improve the original function of ...

  9. Java Reflective learning -4 - Reflection calls method

    Reflection calls method : package cn.tx.reflect; import java.lang.reflect.Constructor; import java.lang.reflect.Method ...

Random recommendation

  1. Study Spring—— Dependency injection

    Preface : I started writing again “ Study Spring” The head of the series …… In fact, I started with “ Study SpringMVC” A few of the articles are out of the understanding of the system Spring as well as SpringMVC, Because usually in the company, although they are used every day Spri ...

  2. 【 turn 】 solve svn Authorization failed error

    Reprinted address :http://blog.sina.com.cn/s/blog_4b93170a0100leb2.html This problem is basically caused by three configuration files , Here's a list of this file svnserve.con ...

  3. yum in baserul The space in the path

    To configure yum Source time , For example, when you specify a locally mounted CD , The path contains spaces . Without Links , use "\" It doesn't work to escape , Add the path to the list . Double quotes don't work either . The correct way to do this is to use %20 Instead of . Empathy , Other unidentifiable ...

  4. Media Player Classic - HC Source code analysis 3: Core class (CMainFrame)(2)

    ===================================================== Media Player Classic - HC Source code analysis series article list : Media P ...

  5. use Cocos2dx Analysis of the development of chess and card games

    as everyone knows , At present, chess and card games are very popular . Many game companies want to make money here , But I don't know what software is better to develop chess and card games , Regarding this , I listed two relatively reliable software to develop chess and card games , Hopefully that helped ! The first software is cocos2d ...

  6. binlog Open and view

    1. First, you need to mysql Of binlog Log open . The default is off . Refer to the website :Windows Next Mysql5.7 Turn on binlog Steps and precautions (https://www.cnblogs.com/wangwu ...

  7. To explore the Entity Framework How to implement the work unit among multiple storage layer instances and its principle (2018-05-31 Modify some critical error codes )

    Preface 1. The premise of this paper is :EF Context is the only thread ,EF edition 6.1.3. 2. It's already on the Internet API Detailed introduction , This article is more as my own personal study and research record . 3.2018-05-31 modify DbSession.cs ...

  8. python Data exchange

    example 1 def change(data): data[],data[]=data[],data[] print(' After swapping positions in a function :') ): print('data[%d]=%3d' %(i,data ...

  9. &lt; turn &gt;Android Develop a method to make the input box click to pop up the date selection dialog box

    It's very simple to code directly : from :http://blog.sina.com.cn/s/blog_4ac1b5f60102vgnx.html final EditText et1=(EditText)find ...

  10. The eighth assignment ——windows Command processing methods for various basic applications