This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
public class Main { | |
public static void main(String[] args) { | |
int[] nums = {1,2,4,5,6}; | |
int target; | |
target = 5; | |
// target = 0; | |
// target = 7; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.my.package; | |
import java.util.Arrays; | |
import java.util.Scanner; | |
public class Main { | |
private static int[] nums = {1,4,5,7,8,9};//Some random SORTED array | |
private static Scanner sc = new Scanner(System.in); | |
public static void main(String[] args) { | |
System.out.println("array ="+ Arrays.toString(nums)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// write to file | |
var txtFile = "c:/test.txt"; | |
var file = new File(txtFile); | |
var str = "My string of text"; | |
file.open("w"); // open file with write access | |
file.writeln("First line of text"); | |
file.writeln("Second line of text " + str); | |
file.write(str); | |
file.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// write to file | |
var txtFile = "c:/test.txt"; | |
var file = new File(txtFile); | |
var str = "My string of text"; | |
file.open("w"); // open file with write access | |
file.writeln("First line of text"); | |
file.writeln("Second line of text " + str); | |
file.write(str); | |
file.close(); |