Friday, October 18, 2013

How sort list of object with multiple data sort in java



package example;

import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Demo {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Demo demo = new Demo();
        List<Student> list = new ArrayList<Student>(); // your Car list
        Student st = demo.new Student();
        st.setName("sekhar");
        st.setCity("bbsr");
        st.setRoll(23);
        list.add(st);
        st = demo.new Student();
        st.setName("himanshu");
        st.setCity("agra");
        st.setRoll(23);
        list.add(st);
        st = demo.new Student();
        st.setName("nitin");
        st.setCity("delhi");
        st.setRoll(23);
        list.add(st);
        st = demo.new Student();
        st.setName("nitin");
        st.setCity("delhi");
        st.setRoll(22);
        list.add(st);
        st = demo.new Student();
        st.setName("nitin");
        st.setCity("bbsr");
        st.setRoll(23);
        list.add(st);
        st = demo.new Student();
        st.setName("arun");
        st.setCity("patna");
        st.setRoll(23);
        list.add(st);
        st = demo.new Student();
        st.setName("arun");
        st.setCity("kendrapara");
        st.setRoll(23);
        list.add(st);
        System.out.println("before sort");
        System.out.println("Name:" + "-------------------" + "City...........roll");
        for (Student st1 : list) {
            System.out.println(st1.getName() + " --------------" + st1.getCity() + "------------" + st1.getRoll());
        }

        Collections.sort(list, demo.new CarHorsePowerComparator());
        System.out.println("after sort");
        System.out.println("Name:" + "-------------------" + "City...............roll");
        for (Student st1 : list) {
            System.out.println(st1.getName() + " --------------" + st1.getCity() + "------------" + st1.getRoll());
        }
    }

    public class Student {

        String name;
        String city;
        int roll;

        public int getRoll() {
            return roll;
        }

        public void setRoll(int roll) {
            this.roll = roll;
        }

        public String getCity() {
            return city;
        }

        public void setCity(String city) {
            this.city = city;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

    class CarHorsePowerComparator implements Comparator<Student> {
        private final Collator collator = Collator.getInstance(); //Default local is taken.

          public int compare(Student left, Student right) {

            int result = collator.compare(left.getName(),right.getName());

            if(result == 0) {
                result = collator.compare(right.getCity(),left.getCity());
            }

            if(result == 0) {
                result = Integer.compare(left.getRoll(), right.getRoll()); //JDK 7
               //result = Double.compare(left.getRoll(), right.getRoll());
            }

            return result;
        }
    }
}


OutPut:

before sort
Name:-------------------City...........roll
sekhar --------------bbsr------------23
himanshu --------------agra------------23
nitin --------------delhi------------23
nitin --------------delhi------------22
nitin --------------bbsr------------23
arun --------------patna------------23
arun --------------kendrapara------------23
after sort
Name:-------------------City...............roll
arun --------------patna------------23
arun --------------kendrapara------------23
himanshu --------------agra------------23
nitin --------------delhi------------22
nitin --------------delhi------------23
nitin --------------bbsr------------23
sekhar --------------bbsr------------23

Tuesday, October 8, 2013

Javascript StartsWith And How to Check Plugin in Firfox and Crome

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <script>
function demo(){
    var L = navigator.plugins.length;
    if (typeof String.prototype.startsWith != 'function') {
  // see below for better implementation!
  String.prototype.startsWith = function (str){
    return this.indexOf(str) == 0;
  };
}

document.write(
  L.toString() + " Plugin(s)<br>" +
  "Name | Filename | description<br>"
);

for(var i = 0; i < L; i++) {
  document.write(
    navigator.plugins[i].name +
    " | " +
    navigator.plugins[i].filename +
    " | " +
    navigator.plugins[i].description +
    " | " +
    navigator.plugins[i].version +
    "<br>"
  );
  var data = navigator.plugins[i].name;
var input = 'Dynamic Web TWAIN';
alert(data.startsWith(input));
}

}
  </script>
 </head>

 <body onLoad="demo();">
 
 </body>
</html>

Tuesday, October 1, 2013

Remove Delta Search features from Internet Explorer

Remove Delta Toolbar from Add-ons manager

  1. Open Internet Explorer.
  2. Click the Tools icon (Cogwheel) and select Manage add-ons.
  3. Under Add-on Types, select Toolbars and Extensions.
  4. In the right pane, select Delta Toolbar & Delta helper Object and click the Disable button.

Remove Delta Toolbar from Windows programs

  1. Click the Start button and select Control Panel.
  2. Select Programs and Features.
  3. Select the Delta Toolbar from the Programs list and right click to uninstall.

Remove Delta Search from default search engines

  1. Open Internet Explorer.
  2. Click the Tools icon (Cogwheel) and select Manage add-ons.
  3. Under Add-on Types, select Search Providers.
  4. Set your preferred default search engine.
  5. Select Delta Search and click the Remove button.

Remove Delta Search home page

  1. Open Internet Explorer.
  2. Click the Tools icon (Cogwheel) and select Internet Options.
  3. In the General tab, delete the Delta URL from the Home page text box.
  4. Click OK to save the changes

Remove Delta Search home page

If you open a new tab in Internet Explorer, and Delta Search home page is still there, please do the following:
  1. Open Internet Explorer, click the Tools icon (Cogwheel) and select Internet Options.
  2. In General tab, click the Tabs button (in the Tabs section).
  3. In the new window, click the drop down menu (When a new tab is opened, open: ), and select the option: Your first home page.
  4. Click OK, Apply and OK in the next window as well.
  5. Restart Internet Explorer.


* Restart your computer after completing all the above steps.

Remove Delta Search features from Google Chrome

Remove Delta Toolbar Extension

  1. Open Chrome.
  2. Click the Customize and control button ("3 streaks” icon or wrench icon in older versions) and select Settings.
  3. Click Extensions in the left menu.
  4. Remove/Disable the Delta Toolbar.

Remove Delta Toolbar from Windows programs

  1. Click on the Start button and select Control Panel.
  2. Select Programs and Features.
  3. Select the Delta Toolbar from the Programs list and right click to uninstall
  4. Click YES on the popup message.

Remove Delta Search from default Search engines

  1. From the Customize and control button ("3 streaks” icon or wrench icon in older versions), select Settings.
  2. In the Search section, click Manage search engines and remove Delta Search from the default search engines list.
  3. Click OK to save the changes.

Remove Delta Search home page

  1. Open Chrome.
  2. Click the Customize and control button ("3 streaks” icon or wrench icon in older versions), select Settings.
  3. In the On Startup section, Click on Set Pages and delete the Delta URL (you can set a different home page by entering a URL of your choice).
  4. Click Ok to save the changes.
  5. In the Appearance section, click on Change and delete the Delta URL (you can set a different home page).
  6. Click Ok to save the changes.


* Restart your computer after completing all the above steps.

Remove Delta Search features from Mozilla Firefox

Remove Delta Toolbar from Add-ons manager

  1. Open Mozilla Firefox.
  2. From the Firefox orange button (Or from the standard Tools menu), click Add-ons.
  3. In Add-ons manager left side menu bar, make sure Extensions is selected
  4. Disable or remove the Delta Toolbar add-on
  5. Restart the browser.

Remove Delta Toolbar from Windows programs

  1. Click the Start button and select Control Panel.
  2. Select Programs and Features.
  3. Select Delta Toolbar from the Programs list and right click to uninstall.
  4. Click YES on the popup message.

Remove Delta Search from default search engines

  1. Open Mozilla Firefox.
  2. Click inside the Search text field and press the F4 key
  3. Select Manage Search Engines from the drop down list
  4. Select Delta Search and click the Remove button.

Remove Delta Search home page

  1. Open Mozilla Firefox.
  2. From the Firefox orange button (or from the standard Tools menu), select Options.
  3. In the General tab, delete the Delta URL from the Home page text box.
  4. Click OK to save the changes.

Remove Delta Search home page from New Tab

If you open a new tab in Firefox, and delta Search home page is still there, please do the following:
  1. Type: about:config in the address bar and press enter
  2. Confirm the message.
  3. Type: browser.newtab.url in the Search text field
  4. Right click on the result and select Toggle (or Reset in older versions)


* Restart your computer after completing all the above steps.

How ChatGPT can Benefit Coding: Your Guide to Leveraging an AI Language Model

 Introduction: Hello, coders! Welcome to this blog post on how ChatGPT, an AI language model, can benefit your coding skills and projects. A...