import java.util.Scanner;
class SecondLargest {
public static void main(String[] args) {
int secondlargest = Integer.MIN_VALUE;
int largest = Integer.MIN_VALUE;
Scanner input = new Scanner(System.in);
System.out.println("Enter array values: ");
int arr[] = new int[5];
for (int i = 0; i < arr.length; i++)
{
arr[i] = input.nextInt();
if (largest < arr[i])
{
secondlargest = largest;
largest = arr[i];
}
if (secondlargest < arr[i] && largest != arr[i])
secondlargest = arr[i];
}
System.out.println("Second Largest number is: " + secondlargest);
}
}
Showing posts with label How To. Show all posts
Showing posts with label How To. Show all posts
Friday, 3 May 2013
Find Second Largest Number In Array Without Sorting
Friday, 19 April 2013
Keyboard Shortcuts (Microsoft Windows)
1. CTRL+C (Copy)
2. CTRL+X (Cut)
... 3. CTRL+V (Paste)
4. CTRL+Z (Undo)
5. DELETE (Delete)
6. SHIFT+DELETE (Delete the selected item permanently without placing the item in the Recycle Bin)
7. CTRL while dragging an item (Copy the selected item)
8. CTRL+SHIFT while dragging an item (Create a shortcut to the selected item)
9. F2 key (Rename the selected item)
10. CTRL+RIGHT ARROW (Move the insertion point to the beginning of the next word)
11. CTRL+LEFT ARROW (Move the insertion point to the beginning of the previous word)
12. CTRL+DOWN ARROW (Move the insertion point to the beginning of the next paragraph)
13. CTRL+UP ARROW (Move the insertion point to the beginning of the previous paragraph)
14. CTRL+SHIFT with any of the arrow keys (Highlight a block of text)
SHIFT with any of the arrow keys (Select more than one item in a window or on the desktop, or select text in a document)
15. CTRL+A (Select all)
16. F3 key (Search for a file or a folder)
17. ALT+ENTER (View the properties for the selected item)
18. ALT+F4 (Close the active item, or quit the active program)
19. ALT+ENTER (Display the properties of the selected object)
20. ALT+SPACEBAR (Open the shortcut menu for the active window)
21. CTRL+F4 (Close the active document in programs that enable you to have multiple documents opensimultaneously)
22. ALT+TAB (Switch between the open items)
23. ALT+ESC (Cycle through items in the order that they had been opened)
24. F6 key (Cycle through the screen elements in a window or on the desktop)
25. F4 key (Display the Address bar list in My Computer or Windows Explorer)
26. SHIFT+F10 (Display the shortcut menu for the selected item)
27. ALT+SPACEBAR (Display the System menu for the active window)
28. CTRL+ESC (Display the Start menu)
29. ALT+Underlined letter in a menu name (Display the corresponding menu) Underlined letter in a command name on an open menu (Perform the corresponding command)
30. F10 key (Activate the menu bar in the active program)
31. RIGHT ARROW (Open the next menu to the right, or open a submenu)
32. LEFT ARROW (Open the next menu to the left, or close a submenu)
33. F5 key (Update the active window)
34. BACKSPACE (View the folder onelevel up in My Computer or Windows Explorer)
35. ESC (Cancel the current task)
36. SHIFT when you insert a CD-ROMinto the CD-ROM drive (Prevent the CD-ROM from automatically playing)
Dialog Box - Keyboard Shortcuts
1. CTRL+TAB (Move forward through the tabs)
2. CTRL+SHIFT+TAB (Move backward through the tabs)
3. TAB (Move forward through the options)
4. SHIFT+TAB (Move backward through the options)
5. ALT+Underlined letter (Perform the corresponding command or select the corresponding option)
6. ENTER (Perform the command for the active option or button)
7. SPACEBAR (Select or clear the check box if the active option is a check box)
8. Arrow keys (Select a button if the active option is a group of option buttons)
9. F1 key (Display Help)
10. F4 key (Display the items in the active list)
11. BACKSPACE (Open a folder one level up if a folder is selected in the Save As or Open dialog box)
Microsoft Natural Keyboard Shortcuts
1. Windows Logo (Display or hide the Start menu)
2. Windows Logo+BREAK (Display the System Properties dialog box)
3. Windows Logo+D (Display the desktop)
4. Windows Logo+M (Minimize all of the windows)
5. Windows Logo+SHIFT+M (Restorethe minimized windows)
6. Windows Logo+E (Open My Computer)
7. Windows Logo+F (Search for a file or a folder)
8. CTRL+Windows Logo+F (Search for computers)
9. Windows Logo+F1 (Display Windows Help)
10. Windows Logo+ L (Lock the keyboard)
11. Windows Logo+R (Open the Run dialog box)
12. Windows Logo+U (Open Utility Manager)
13. Accessibility Keyboard Shortcuts
14. Right SHIFT for eight seconds (Switch FilterKeys either on or off)
15. Left ALT+left SHIFT+PRINT SCREEN (Switch High Contrast either on or off)
16. Left ALT+left SHIFT+NUM LOCK (Switch the MouseKeys either on or off)
17. SHIFT five times (Switch the StickyKeys either on or off)
18. NUM LOCK for five seconds (Switch the ToggleKeys either on or off)
19. Windows Logo +U (Open Utility Manager)
20. Windows Explorer Keyboard Shortcuts
21. END (Display the bottom of the active window)
22. HOME (Display the top of the active window)
23. NUM LOCK+Asterisk sign (*) (Display all of the subfolders that are under the selected folder)
24. NUM LOCK+Plus sign (+) (Display the contents of the selected folder)
25. NUM LOCK+Minus sign (-) (Collapse the selected folder)
26. LEFT ARROW (Collapse the current selection if it is expanded, or select the parent folder)
27. RIGHT ARROW (Display the current selection if it is collapsed, or select the first subfolder)
Shortcut Keys for Character Map
After you double-click a character on the grid of characters, you can move through the grid by using the keyboard shortcuts:
1. RIGHT ARROW (Move to the rightor to the beginning of the next line)
2. LEFT ARROW (Move to the left orto the end of the previous line)
3. UP ARROW (Move up one row)
4. DOWN ARROW (Move down one row)
5. PAGE UP (Move up one screen at a time)
6. PAGE DOWN (Move down one screen at a time)
7. HOME (Move to the beginning of the line)
8. END (Move to the end of the line)
9. CTRL+HOME (Move to the first character)
10. CTRL+END (Move to the last character)
11. SPACEBAR (Switch between Enlarged and Normal mode when a character is selected)
Microsoft Management Console (MMC)
Main Window Keyboard Shortcuts
1. CTRL+O (Open a saved console)
2. CTRL+N (Open a new console)
3. CTRL+S (Save the open console)
4. CTRL+M (Add or remove a console item)
5. CTRL+W (Open a new window)
6. F5 key (Update the content of all console windows)
7. ALT+SPACEBAR (Display the MMC window menu)
8. ALT+F4 (Close the console)
9. ALT+A (Display the Action menu)
10. ALT+V (Display the View menu)
11. ALT+F (Display the File menu)
12. ALT+O (Display the Favorites menu)
MMC Console Window Keyboard Shortcuts
1. CTRL+P (Print the current page or active pane)
2. ALT+Minus sign (-) (Display the window menu for the active console window)
3. SHIFT+F10 (Display the Action shortcut menu for the selected item)
4. F1 key (Open the Help topic, if any, for the selected item)
5. F5 key (Update the content of all console windows)
6. CTRL+F10 (Maximize the active console window)
7. CTRL+F5 (Restore the active console window)
8. ALT+ENTER (Display the Properties dialog box, if any, for theselected item)
9. F2 key (Rename the selected item)
10. CTRL+F4 (Close the active console window. When a console has only one console window, this shortcut closes the console)
Remote Desktop Connection Navigation
1. CTRL+ALT+END (Open the Microsoft Windows NT Security dialog box)
2. ALT+PAGE UP (Switch between programs from left to right)
3. ALT+PAGE DOWN (Switch between programs from right to left)
4. ALT+INSERT (Cycle through the programs in most recently used order)
5. ALT+HOME (Display the Start menu)
6. CTRL+ALT+BREAK (Switch the client computer between a window and a full screen)
7. ALT+DELETE (Display the Windows menu)
8. CTRL+ALT+Minus sign (-) (Place a snapshot of the active window in the client on the Terminal server clipboard and provide the same functionality as pressing PRINT SCREEN on a local computer.)
9. CTRL+ALT+Plus sign (+) (Place asnapshot of the entire client window area on the Terminal server clipboardand provide the same functionality aspressing ALT+PRINT SCREEN on a local computer.)
Microsoft Internet Explorer Keyboard Shortcuts
1. CTRL+B (Open the Organize Favorites dialog box)
2. CTRL+E (Open the Search bar)
3. CTRL+F (Start the Find utility)
4. CTRL+H (Open the History bar)
5. CTRL+I (Open the Favorites bar)
6. CTRL+L (Open the Open dialog box)
7. CTRL+N (Start another instance of the browser with the same Web address)
8. CTRL+O (Open the Open dialog box,the same as CTRL+L)
9. CTRL+P (Open the Print dialog box)
10. CTRL+R (Update the current Web page)
11. CTRL+W (Close the current window)
Monday, 25 February 2013
Between 11:20 to 12:00 of specified date Java
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minutes = cal.get(Calendar.MINUTE);
if (hour == 11 && minutes >= 20 || hour == 12 && minutes <= 0)
{
//Your Logic
}
Get Next Date In Java
public class NextDate
{ public static void main(String[] args)
{
int oneDay = 1000 * 60 * 60 * 24;
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
String currDate = dateFormat.format(date.getTime());
String nextDate = dateFormat.format(date.getTime() + oneDay);
System.out.println("Currnent date: " + currDate);
System.out.println("Next date: " + nextDate);
}
}
Friday, 1 February 2013
Turn Your Windows 7 PC Into a Wireless Hotspot
Everybody's got a wireless network at home, but if you've ever wanted to get your iPod touch, iPhone, or other wireless device connected, but all you've got is a wired network at work, school, or elsewhere, Windows 7 makes this process trivial.
Not using Windows 7 yet? You can accomplish the same thing in Windows Vista, XP, and even OS X—the Windows Vista method is almost identical to Windows 7, but XP requires a few more steps.
Before we begin, you should make sure that you've got a laptop or desktop with a wireless card that isn't currently connected—if your laptop is connected to the wired network, your wireless card should be free, and we can use it to allow access to the internet. Note that you have to be plugged into a wired connection in order to share the connection wirelessly with others, or have a second wireless card. Readers should also note that this won't work on (some) work networks that use group policies to enforce TPS report cover sheet boredom and prevent you from having any fun at all.
You'll be prompted with a wizard that allows you to connect to VPNs, dial-up, or create a new ad hoc wireless network, which is what we want to do. You can easily use an ad hoc network to share files back and forth between two computers, but today we'll be using it for sharing the internet connection.
You'll need to give your network a name and choose some security options—remember that WEP is extremely easy to crack—and you'll want to make sure to use at least a decent sized key even for WPA2. The really important option on this page is to remember to check the box for "Save this network".
You'll notice that the ad hoc networks that you create get added to the quick-select wireless network list—when you disconnect from your ad hoc network, it's the same as stopping it. Connecting to the network is the same as starting it back up; this way you can quickly switch back and forth between connections with just a few clicks.
At this point, you should be able to connect any wireless device to your new ad hoc network and access the internet, or even share files directly with your laptop.
Have you been able to successfully get your wireless device connected to your PC? Tell us about your experience in the comments.
Wednesday, 30 January 2013
What Are Magnet Links
Soon, popular torrent site The Pirate Bay will no longer host torrent files. Instead, it will only offer magnet links. Magnet what now?
You may have seen the term "magnet link" before, but if you haven't
used one, here's the lowdown on what this change means for you as a
BitTorrent user.
A magnet link does away with the middleman. A magnet link is essentially a hyperlink containing the hash code for that torrent, which your torrent client can immediately use to start finding people sharing those files. Magnet links don't require a tracker (since it uses DHT, which you can read more about here), nor does it require you to download a separate file before starting the download, which is convenient.
Magnet
links are dead simple to use. If you head to the Pirate Bay now, you'll
notice that magnet links are now the default, with the "Get Torrent
File" link in parentheses next to it (a link which will disappear in a
month or so). Just click on the magnet link, and your browser should
automatically open up your default BitTorrent client and start
downloading. It's that easy.
The main reason torrent sites are moving toward magnet links—apart from convenience to the user—is that these links (probably) free torrent sites like The Pirate Bay from legal trouble. Since The Pirate Bay won't be hosting files that link to copyrighted content—that is, the torrent files—it's more difficult to claim the site is directly enabling the downloading of copyrighted material. Whether this semantic leap actually protects torrent sites remains to be seen, but for now, you can sleep soundly knowing that the sites will stick around for awhile longer and that your torrents will take one less click to get started. Of course, if you're using a public site like The Pirate Bay, we highly recommend you set up a proxy and encryption service like BTGuard to protect your downloading from prying eyes. If you want to read more about magnet links, check out the Wikipedia page on the subject.
How Magnet Links Are Different From .Torrent Files
When you download a .torrent file, you're essentially downloading a small file that contains information on the larger files you want to download. The torrent file tells your torrent client the names of the files being shared, a URL for the tracker, and more. Your torrent client then calculates a hash code, which is a unique code that only that torrent has—kind of like an ISBN or catalog number. From there, it can use that code to find others uploading those files, so you can download from them.A magnet link does away with the middleman. A magnet link is essentially a hyperlink containing the hash code for that torrent, which your torrent client can immediately use to start finding people sharing those files. Magnet links don't require a tracker (since it uses DHT, which you can read more about here), nor does it require you to download a separate file before starting the download, which is convenient.
How to Use Magnet Links
What This Ultimately Means for You
The short answer is nothing. In fact, it could mean that downloading torrents takes one or two fewer clicks, since all you have to do is click on the link to start the download. When magnet links first came out, not all torrent clients supported them, but now you can use magnet links with just about any semi-popular torrent client out there—including our favorites uTorrent, Transmission, and Deluge, among others, so you shouldn't notice a problem with that.The main reason torrent sites are moving toward magnet links—apart from convenience to the user—is that these links (probably) free torrent sites like The Pirate Bay from legal trouble. Since The Pirate Bay won't be hosting files that link to copyrighted content—that is, the torrent files—it's more difficult to claim the site is directly enabling the downloading of copyrighted material. Whether this semantic leap actually protects torrent sites remains to be seen, but for now, you can sleep soundly knowing that the sites will stick around for awhile longer and that your torrents will take one less click to get started. Of course, if you're using a public site like The Pirate Bay, we highly recommend you set up a proxy and encryption service like BTGuard to protect your downloading from prying eyes. If you want to read more about magnet links, check out the Wikipedia page on the subject.