Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Wednesday, September 14, 2016

Googles 5G Drones will Make Internet 40 times Faster Than 4G

,
 Googles 5G Drones will Make Internet 40 times Faster Than 4G
The Guardian has reported that “Google is testing Solar Powered Drones at Spaceport America in New Mexico to discover ways of bringing high speed Internet via Air”.

These Secret project by Google  is planned to prototype transceivers and drones, this is done by using millimeter wave transmission. The projected itself is code-named SkyBender, one of Googles project committed to making available cheap internet using balloons.

Document from public record laws state that Google built many prototype transceivers at the far-flung spaceport previous summer and now testing them with several drones. Millimeter transmissions covers a frequency of 28 GHz which may be low to 4G technologies but a lot speedier. Millimeter Waves can transfer a good volume of Gigabytes of data per second and that is 40 times faster than 4G technologies.

A flight dedicated control center has been built by Google very close to the spacecraft operation center at a special location different from the terminal. The

Googles 5G technology Drones can capably make available cheap internet for Global users, the range is shorter, but the speed is tremendous, the team at Google is presently working on how to make its coverage broader

The Guardian

Read more

Saturday, August 20, 2016

Program for calculator in JAVA

,
This is the source code for a calculater in java
import java.io.*;
import java.awt.*;
import java.applet.*;
import javax.swing.*;
import java.awt.event.*;

public class Calculator extends JApplet implements ActionListener
{
int choice;
double a,b, result = 0;
String str;
JTextField jt;
JButton btn0, btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9;
JButton btnAdd, btnSub, btnMul, btnDiv, btnEqual, btnDot, btnCl;
JPanel pn1, pn2;
Container cp;
public void init() // Initializing Applet & its Components
{
cp = getContentPane();
cp.setLayout ( new BorderLayout() );
jt = new JTextField(10);
jt.setHorizontalAlignment(4);
pn1 = new JPanel();
pn2 = new JPanel();
pn1.setLayout ( new FlowLayout() );
pn2.setLayout ( new GridLayout(4, 4) );
btnCl = new JButton ("Clear");
btn0 = new JButton ("0");
btn1 = new JButton ("1");
btn2 = new JButton ("2");
btn3 = new JButton ("3");
btn4 = new JButton ("4");
btn5 = new JButton ("5");
btn6 = new JButton ("6");
btn7 = new JButton ("7");
btn8 = new JButton ("8");
btn9 = new JButton ("9");
btnAdd = new JButton ("+");
btnSub = new JButton ("-");
btnMul = new JButton ("*");
btnDiv = new JButton ("/");
btnEqual = new JButton ("=");
btnDot = new JButton (".");
addButtons();
addListeners();
pn1.add (jt);
pn1.add (btnCl);
cp.add (pn1, BorderLayout.NORTH);
cp.add (pn2, BorderLayout.CENTER);
jt.setText("");
}

public void addListeners() // Adding Listeners to all Components
{
btn0.addActionListener ( this );
btn1.addActionListener ( this );
btn2.addActionListener ( this );
btn3.addActionListener ( this );
btn4.addActionListener ( this );
btn5.addActionListener ( this );
btn6.addActionListener ( this );
btn7.addActionListener ( this );
btn8.addActionListener ( this );
btn9.addActionListener ( this );
btnDot.addActionListener ( this );
btnCl.addActionListener ( this );
btnAdd.addActionListener ( this );
btnSub.addActionListener ( this );
btnMul.addActionListener ( this );
btnDiv.addActionListener ( this );
btnEqual.addActionListener ( this );
}

public void addButtons() // Adding all Components to JPanel
{
pn2.add ( btn7 );
pn2.add ( btn8 );
pn2.add ( btn9 );
pn2.add ( btnDiv );
pn2.add ( btn4 );
pn2.add ( btn5 );
pn2.add ( btn6 );
pn2.add ( btnMul );
pn2.add ( btn1 );
pn2.add ( btn2 );
pn2.add ( btn3 );
pn2.add ( btnSub );
pn2.add ( btn0 );
pn2.add ( btnDot );
pn2.add ( btnAdd );
pn2.add ( btnEqual );
}
public void operation(double a, double b, int op)
{
switch ( choice )
{
case 1 :
{ result = a + b; break; }
case 2 :
{ result = a - b; break; }
case 3 :
{ result = a * b; break; }
case 4 :
{ result = a / b; break; }
default :
{ jt.setText("0"); break; }
}
}

public void actionPerformed(ActionEvent e) // Actions to be performed
{ // whenever event is triggered
try
{
str = (String)e.getActionCommand();
if ( str = = "+" )
{
a=Double.parseDouble (jt.getText());
jt.setText("");
choice = 1;
}
else if ( str = = "-" )
{
a=Double.parseDouble (jt.getText());
jt.setText("");
choice = 2;
}
else if ( str = = "*" )
{
a=Double.parseDouble (jt.getText());
jt.setText("");
choice = 3;
}
else if ( str = = "/" )
{
a=Double.parseDouble (jt.getText());
jt.setText("");
choice = 4;
}
else if ( str = = "=" )
{
b = Double.parseDouble (jt.getText());
operation(a, b, choice);
jt.setText("");
System.out.println(result);
}
else if ( str = = "Clear" )
{
jt.setText("");
choice = 0;
a = b = result = 0;
}
else
{
jt.setText( jt.getText() +str );
}
}
catch(Exception ex)
{
jt.setText("Invalid Operation");
System.out.println("Invalid Operation");
}
}
}

//<applet code="Calculator.class" width=200 height=200></applet>
Read more

Monday, July 4, 2016

Oracle to terminate Java Browser Plugin

,
Oracle has announced that it is terminating its Java Browser Plugin. It is going to discontinue this plugin technology in Java Developer Kit 9 and eliminate it entirely from oracle JDK and Java Run time Environment in a future Java SE release.
Oracle has confessed this week, that plugins have went out of date and current internet browsers no longer require them for functioning. Previously, Google Chrome began to disable Java in April 2015. Firefox also planned to kill Oracle’s Java Plugin last year. Oracle is saying its developers to build that technology or which is dependent on the Java Browser Plugin to find its replacement.

Oracle in blog post said “With modern browser vendors working to restrict and reduce plugin support in their products, developers of applications that rely on the Java browser plugin need to consider alternative options such as migrating from Java Applets (which rely on a browser plugin) to the plugin-free Java Web Start technology”.

Oracle purchased Sun Microsystems and by extension the Java in the year 2010. The Oracle’s Java plugin is similar to Adobe’s Flash and Microsoft’s Silver-light utilizes NPAPI, old Netscape plugin API. For the period of time, these plugins however caused difficulty rather than doing good. We also witnessed many security attacks that had Java Plugin as the target link.

Although, not everyone will be excited about the removal of Java. Many Enterprises are probably using old browsers that require java and created many application for them same. The developers wont be happy with Oracle’s decision.

So, this was all about the decision of Oracle to kill Java. Many Browsers also decided to disable this plugin. We hope that you loved this article, feel free to share this with your friends.
Read more

Saturday, July 12, 2014

How to Sort Array in Java ascending and descending order of elements with Example

,
Quite often we need to sort array in Java luckily java.util.Arrays class provide several utility method to sort java array of any type e.g. primitive, object or int, String etc. Arrays is in java.util package and exposed all sorting related method as static utility functions. you can access sort() as Arrays.sort() and just pass your array and it will sort that array object. You can sort array in ascending order, descending order or any custom order defined by custom comparator in Java. In last article we have seen how to Sort ArrayList in Java and in this java article we will see examples of sorting array in ascending order, descending order and sorting sub arrays in java.

Sort Array in Java on ascending and descending order

Sorting Java Array into Ascending Order:

how to sort array in java ascending descending order exampleIn order to sort an array (String, int or any type) in ascending order we dont need to to anything special. Arrays.sort() method by default sort elements in there natural order implemented by CompareTo method. String array in Java will be sorted lexicographically. integer will be sorted numerically ascending order. look on code section for complete example of how to sort java array into ascending order. You can also sort anonymous array in Java by this method but since you don’t have any name to refer that it doesn’t make much sense.

Sorting Java Array into Descending Order:

In order to sort a java array into descending order you need to provide an external Comparator in Java which can sort elements in there reverse order and luckily we have that built int as java.util.Collections.reverseOrder(), which returns a reverse order comparator which gives reverse of natural ordering of element objects. pass this reverse comparator to sort method and it will sort array into descending order as shown in code example on last section. There is another way in which you can convert Array into ArrayList and than sort the arraylist but that’s again a two step process so its better to sort array using Arrays.sort() method



Sorting Sub Array in Java

Arrays class also provide methods to sort part of java array or sub array. So in case if you have big array and you only need to sort a particular section than just provide start index and end index to java.util.Arrays.sort(array,index,index) and it will sort the array only for that range. this is much faster than sorting whole array and than getting a range of values out of it. here is code example of sorting part of array in Java:


Code Example of Sorting Array in Java

In this section of code example we will see how to sort Java array into ascending order, descending order and sorting sub arrays in Java:


import java.util.Arrays;
import java.util.Collections;

public class HashtableDemo {

public static void main(String args[]) {
String[] companies = { "Google", "Apple", "Sony" };

// sorting java array in ascending order
System.out.println("Sorting String Array in Ascending order in Java Example");
System.out.println("Unsorted String Array in Java: ");
printNumbers(companies);
Arrays.sort(companies);
System.out.println("Sorted String Array in ascending order : ");
printNumbers(companies);

// sorting java array in descending order
System.out.println("Sorting Array in Descending order in Java Example");
System.out.println("Unsorted int Array in Java: ");
printNumbers(companies);
Arrays.sort(companies, Collections.reverseOrder());
System.out.println("Sorted int Array in descending order : ");
printNumbers(companies);

System.out.println("Sorting part of array in java:");
int[] numbers = { 1, 3, 2, 5, 4 };
Arrays.sort(numbers, 0, 3);
System.out.println("Sorted sub array in Java: ");
for (int num : numbers) {
System.out.println(num);
}

}

public static void printNumbers(String[] companies) {
for (String company : companies) {
System.out.println(company);
}
}

}

Output:
Sorting String Array in Ascending order in Java Example
Unsorted String Array in Java:
Google
Apple
Sony

Sorted String Array in ascending order :
Apple
Google
Sony

Sorting Array in Descending order in Java Example
Unsorted int Array in Java:
Apple
Google
Sony
Sorted String Array in descending order :
Sony
Google
Apple
Sorting part of array in java:
Sorted sub array in Java:
1
2
3
5
4



Important points about Sort method of Arrays:

Here are some important and worth noting point about sort method of Arrays class for quick references:

1. Arrays.sort() is an overloaded method and can sort int, byte, short, char or object[] arrays.
2. Arrays.sort)( also allows you to sort a sub-array or part of array in Java.
3. Arrays class also contains utility methods e.g. binarySearch for performing search on array

That’s all on how to sort java array on ascending and descending order and part of array in Java. You can also use the workaround by converting array into arraylist and than sorting but I think Arrays.sort() is preferred method for sorting arrays in Java.

Java Tutorials you may like


Read more
 

Computer Info Copyright © 2016 -- Powered by Blogger