code stringlengths 146 466k | prompt stringlengths 54 1.5k |
|---|---|
Of course, here is the Java code you requested:
```java
public void markChildNodes(Vector<BoxNode> list)
{
final Box thisBox = this.getBox();
for (Iterator<BoxNode> it = list.iterator(); it.hasNext();)
{
BoxNode node = it.next();
if (node != this && node.getBox().ge... | Create a Java method that does the following: "Mark all child boxes in the list as nearest parent of this box.". |
Of course, here is the Java code you requested:
```java
@Override
public <T> T getService(Class<T> requiredType) {
return getService(requiredType, ANY_HINT);
}
```
Hope this helps! | Create a Java method that does the following: "Get the service from the cache.". |
Of course, here is the Java code you requested:
```java
protected void process(String command) {
try {
Method method = this.getClass().getMethod(command);
logger.info("Try to delegate '{}' to launcher directly.", command);
method.invoke(this);
logger.info("Invoke... | Create a Java method that does the following: "Process a single command.". |
Of course, here is the Java code you requested:
```java
public static int mainWithExitCode(String[] args) throws Exception {
LaunchEnvironment environment = detectEnvironment();
Component mainComponent = null;
try {
logger.debug(banner("Resolving starts from {}", args[0]));
... | Create a Java method that does the following: "Main with exit code.". |
Of course, here is the Java code you requested:
```java
protected <T> void exports(Class<T> serviceClass, T service) {
exporter.exports(serviceClass, service);
}
```
Hope this helps! | Create a Java method that does the following: "Exports the service.". |
Of course, here is the Java code you requested:
```java
public static void initApplicationEventMulticaster(GenericApplicationContext context) {
ApplicationEventMulticaster multicaster;
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
if (beanFactory.containsLocalBean(APPL... | Create a Java method that does the following: "Initialize the application event multicaster.". |
Of course, here is the Java code you requested:
```java
@Bean
public DataSource dataSource_plain() {
SimpleDriverDataSource ds =
new SimpleDriverDataSource();
ds.setDriverClass(null);
ds.setUrl("jdbc:oracle:thin:@<server>[:<1521>]:<database_name>");
... | Create a Java method that does the following: "DataSource for plain database.". |
Of course, here is the Java code you requested:
```java
public static void setCache(boolean checkCache) {
if ( OpenStates.checkCache != checkCache ) logger.fine("Changing checkCache setting to:" + checkCache );
OpenStates.checkCache = checkCache;
}
```
Hope this helps! | Create a Java method that does the following: "Sets the cache flag.". |
Of course, here is the Java code you requested:
```java
public <T> T query(MethodMap methodMap, ArgMap argMap, Class<T> responseType ) throws OpenStatesException {
BufferedReader reader = null;
HttpURLConnection conn = null;
String charSet = "utf-8";
try {
if ( isCaching(methodMap, argMap) ) {
File file... | Create a Java method that does the following: "Query the OpenStates API.". |
Of course, here is the Java code you requested:
```java
public void register(String name, Command command) {
Preconditions.checkArgument(name != null && !name.isEmpty(), "Parameter 'name' must not be [" + name + "]");
Preconditions.checkArgument(command != null, "Parameter 'command' must not be [" + command + "]")... | Create a Java method that does the following: "Registers a command with the command manager.". |
Of course, here is the Java code you requested:
```java
public void unregister(String name) {
Preconditions.checkArgument(name != null && !name.isEmpty(), "Parameter 'name' must not be [" + name + "]");
commands.remove(name);
}
```
Hope this helps! | Create a Java method that does the following: "Unregister a command.". |
Of course, here is the Java code you requested:
```java
public void start() {
repl.set(true);
String line = null;
while (repl.get() && ((line = console.readLine()) != null)) {
exec(line);
}
}
```
Hope this helps! | Create a Java method that does the following: "Start the process.". |
Of course, here is the Java code you requested:
```java
public Committees searchByState(String state) throws OpenStatesException {
return api.query(
new MethodMap("committees"),
new ArgMap("state", state),
Committees.class
);
}
```
Hope this helps! | Create a Java method that does the following: "Search by state". |
Of course, here is the Java code you requested:
```java
public Committee detail(String id) throws OpenStatesException {
return api.query(new MethodMap("committees", id), null, Committee.class);
}
```
Hope this helps! | Create a Java method that does the following: "Get the details of a committee.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
public static <T> T getMBean(Class<T> interfaceClass, ObjectName objectName, Properties environment) throws MBeanException {
JMXConnector connector = null;
// Get the JMX environment properties.
String ... | Create a Java method that does the following: "Get an instance of the specified interface class and object name using the specified environment.". |
Of course, here is the Java code you requested:
```java
private static String getProperty(Properties properties, String key) {
// Check if the properties do not exist.
if (properties == null || properties.getProperty(key) == null) {
throw new IllegalArgumentException("The property " + key ... | Create a Java method that does the following: "Get the value of a resource class attribute.". |
Of course, here is the Java code you requested:
```java
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object result;
JMXConnector connector = null;
try {
// Connect to the JMX service.
connector = connect(thi... | Create a Java method that does the following: "Override the default implementation of the method.". |
Of course, here is the Java code you requested:
```java
@Override
public int complete(String buffer, int cursor, List<CharSequence> candidates) {
SortedSet<String> commands = new TreeSet<>(shell.commands().keySet());
if (buffer == null) {
candidates.addAll(commands);
} else {
for (String match : comman... | Create a Java method that does the following: "Completes the command.". |
Of course, here is the Java code you requested:
```java
public ResourceSelection getSelection(final String catalog) {
checkReload();
Set<ResourceSelection> result = set.getSelections(catalog);
return Iterables.getFirst(result, null);
}
```
Hope this helps! | Create a Java method that does the following: "Get the first resource selection in the catalog.". |
Of course, here is the Java code you requested:
```java
public Set<ResourceSelection> checkDiff(final ResourceContextConfig target) {
checkReload();
return set.checkDiff(target.set);
}
```
Hope this helps! | Create a Java method that does the following: "Checks if the set and target set are not identical.". |
Of course, here is the Java code you requested:
```java
public Set<String> catalogNames() {
Set<String> catalogs = new HashSet<>();
for (ResourceSelection selection : selections) {
catalogs.add(selection.getCatalog());
}
return catalogs;
}
```
Hope this helps! | Create a Java method that does the following: "Returns a set of catalog names for all the resources in the catalog selection set.". |
Of course, here is the Java code you requested:
```java
public Set<String> resourceNames(final String catalog) {
Set<String> resources = new HashSet<>();
for (ResourceSelection selection : selections) {
if (selection.getCatalog().equals(catalog)) {
resources.add(selection.getName());
}
}
return resou... | Create a Java method that does the following: "Returns the names of all resources in the catalog.". |
Of course, here is the Java code you requested:
```java
public Set<ResourceSelection> getSelections(final String catalog, final String name) {
Set<ResourceSelection> result = new HashSet<>();
for (ResourceSelection selection : selections) {
if (selection.getCatalog().equals(catalog) && selection.getName().equal... | Create a Java method that does the following: "Gets the selections.". |
Of course, here is the Java code you requested:
```java
public Set<ResourceSelection> checkDiff(final ResourceSelectionSet target) {
// 更新信息列表
Set<ResourceSelection> diffs = new HashSet<>();
// 读取源版本
Set<ResourceSelection> sourceEntrys = selections;
if (LOG.isDebugEnabled()) {
LOG.debug("源版本:{}", sourceE... | Create a Java method that does the following: "Check if two resource selections are different.". |
Of course, here is the Java code you requested:
```java
public static FilterBinder forClass(
Binder binder,
Class<? extends Filter> filterClass) {
Preconditions.checkNotNull(binder, "Binder cannot be null.");
Preconditions.checkNotNull(filterClass, "Filter Class cannot be null.... | Create a Java method that does the following: "Create a new FilterBinder for the given class.". |
Of course, here is the Java code you requested:
```java
public void bind() {
FilterSpec fitlerSpec = new FilterSpec(
filterProvider,
priority,
name.or(filterClass.getSimpleName()),
buildPatterns());
Multibinder
.newSetBind... | Create a Java method that does the following: "Binds the CRUD to the FITLER.". |
Of course, here is the Java code you requested:
```java
protected void bindJerseyComponent(Object resource) {
Preconditions.checkNotNull(resource, "Resource cannot be null.");
buildBinders();
jerseyBinder.addBinding().toInstance(resource);
}
```
Hope this helps! | Create a Java method that does the following: "Binds the specified resource to the Jersey Component.". |
Of course, here is the Java code you requested:
```java
public Resource getResource(final ResourceSelection selection) {
if (LOG.isTraceEnabled()) {
LOG.trace("定位资源:{}", selection);
}
String catalog = selection.getCatalog();
String version = selection.getVersion();
String name = selection.getName();
St... | Create a Java method that does the following: "Get a resource from the catalog.". |
Of course, here is the Java code you requested:
```java
public String formatAll() {
StringBuilder sb = new StringBuilder();
formatAll(sb, 0);
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}
```
Hope this helps! | Create a Java method that does the following: "Format all the records in the database.". |
Of course, here is the Java code you requested:
```java
private void formatAll(final StringBuilder sb, final int depth) {
for (int i = 0; i < depth; i++) {
sb.append('\t');
}
format(sb);
sb.append('\n');
for (CodedMessage message : messages) {
message.formatAll(sb, depth + 1);
}
}
```
Hope... | Create a Java method that does the following: "Formats all the related data structures.". |
Of course, here is the Java code you requested:
```java
public Districts search(String state, String chamber) throws OpenStatesException {
return api.query(new MethodMap("districts", state, chamber), null, Districts.class);
}
```
Hope this helps! | Create a Java method that does the following: "Search for districts for a given state and chamber". |
Of course, here is the Java code you requested:
```java
public District boundaryLookup(String boundary_id) throws OpenStatesException {
return api.query(new MethodMap("districts", "boundary", boundary_id ), null, District.class);
}
```
Hope this helps! | Create a Java method that does the following: "Lookup a district by boundary_id". |
Of course, here is the Java code you requested:
```java
public Metadata state(String state) throws OpenStatesException {
return api.query(new MethodMap("metadata", state), null, Metadata.class);
}
```
Hope this helps! | Create a Java method that does the following: "Get the metadata for the given state.". |
Of course, here is the Java code you requested:
```java
private static <T> T createObject(Class<T> interfaceClass) {
ServiceLoader<T> loader = ServiceLoader.load(interfaceClass);
T object = null;
// Loop through the services.
for (T loadedObject : loader) {
// Ch... | Create a Java method that does the following: "Create an object from the interface class.". |
Of course, here is the Java code you requested:
```java
public static <T> T getMBean(Class<T> interfaceClass, Properties environment) throws MBeanException {
return getMBean(interfaceClass, getObjectName(interfaceClass), environment);
}
```
Hope this helps! | Create a Java method that does the following: "Get an MBean by interface class.". |
Of course, here is the Java code you requested:
```java
public static <T> T getMBean(Class<T> interfaceClass, ObjectName objectName, Properties environment) throws MBeanException {
return RemoteMBeanInvocationHandler.getMBean(interfaceClass, objectName, environment);
}
```
Hope this helps! | Create a Java method that does the following: "Get an MBean by interfaceClass and objectName". |
Of course, here is the Java code you requested:
```java
public static <T> ObjectName register(Class<T> interfaceClass, String key, String value) throws MBeanException {
return register(interfaceClass, getObjectName(interfaceClass, key, value));
}
```
Hope this helps! | Create a Java method that does the following: "Register an interface class with the specified key and value.". |
Of course, here is the Java code you requested:
```java
public static <T> ObjectName register(Class<T> interfaceClass, Hashtable<String,String> table) throws MBeanException {
return register(interfaceClass, getObjectName(interfaceClass, table));
}
```
Hope this helps! | Create a Java method that does the following: "Register an interface class with a table of attributes.". |
Of course, here is the Java code you requested:
```java
public static <T> ObjectName register(Class<T> interfaceClass, ObjectName objectName) throws MBeanException {
// Check if the interface class is valid.
if (interfaceClass == null) {
throw new IllegalArgumentException("The interface cl... | Create a Java method that does the following: "Register an interface with the platform MBean server.". |
Of course, here is the Java code you requested:
```java
public static void unregister(ObjectName objectName) throws MBeanException {
try {
// Get the MBean server.
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
// Check if the MBean is registered wi... | Create a Java method that does the following: "Unregister an MBean with the platform MBeanServer.". |
Of course, here is the Java code you requested:
```java
protected static void validateMBean(Class interfaceClass, ObjectName objectName, MBeanServerConnection mBeanServerConnection) throws MBeanException {
try {
// Check if the interface class is null.
if (interfaceClass == null) {
... | Create a Java method that does the following: "Validate the MBean.". |
Of course, here is the Java code you requested:
```java
@Override
public void initialize(Bootstrap<PlatformConfiguration> bootstrap) {
for (Initializer initializer : wrapper.getInitializers()) {
initializer.initialize(bootstrap);
LOGGER.debug("Registered Initializer: {}", initialize... | Create a Java method that does the following: "Initialize the application.". |
Of course, here is the Java code you requested:
```java
@Override
public void run(PlatformConfiguration configuration, Environment environment) throws Exception {
dropwizardModule.setup(configuration, environment);
for (Configurator configurator : wrapper.getConfigurators()) {
configur... | Create a Java method that does the following: "Run the application.". |
Of course, here is the Java code you requested:
```java
@Override
public String get() {
try (final Timer.Context context = timer.time()) {
final String s = randomUUID().toString();
if (length == 0 || count == 0) {
return s;
}
final StringJo... | Create a Java method that does the following: "Get a random ID from the array of tokens.". |
Of course, here is the Java code you requested:
```java
public static void loadDefinitions(final Locale locale, final Resource resource) {
try {
XMLConfiguration config = new XMLConfiguration();
config.setDelimiterParsingDisabled(true);
config.load(resource.getInputStream());
for (HierarchicalConfig... | Create a Java method that does the following: "Load the definitions from the specified resource.". |
Of course, here is the Java code you requested:
```java
public void addValue(String value, boolean isDefault) {
p("Adding " + (isDefault ? "default " : "") + "value:" + value + " to parameter:" + m_field.getName());
String name = m_wrappedParameter.names()[0];
if (m_assigned && !isMultiOption()... | Create a Java method that does the following: "Add a value to the parameter.". |
Of course, here is the Java code you requested:
```java
public Bills searchByDate(
String state,
String updated_since,
String page,
String per_page
) throws OpenStatesException {
OpenStates.suspendCache();
Bills bills = api.query(
new MethodMap("bills"),
new ArgMap(
"state", state... | Create a Java method that does the following: "Returns a list of Bills matching the specified criteria.". |
Of course, here is the Java code you requested:
```java
public Bill detail( String state, String session, String number) throws OpenStatesException {
return api.query( new MethodMap("bills", state, session, number), null, Bill.class);
}
```
Hope this helps! | Create a Java method that does the following: "Get the details of a specific bill.". |
Of course, here is the Java code you requested:
```java
public Bill detailById( String bill_id) throws OpenStatesException {
return api.query( new MethodMap("bills", bill_id), null, Bill.class);
}
```
Hope this helps! | Create a Java method that does the following: "Get details of a specific bill". |
Of course, here is the Java code you requested:
```java
public Legislators searchByStateActive(
String state,
Boolean active
) throws OpenStatesException {
return api.query(
new MethodMap("legislators"),
new ArgMap(
"state", state,
"active", active.toString()
),
Legislators.... | Create a Java method that does the following: "Search by state active". |
Of course, here is the Java code you requested:
```java
public Legislators searchByStateTerm(
String state,
String term
) throws OpenStatesException {
return api.query(
new MethodMap("legislators"),
new ArgMap(
"state", state,
"term", term
),
Legislators.class
);
}
```... | Create a Java method that does the following: "Search by state and term". |
Of course, here is the Java code you requested:
```java
@Override
public String getPrefix() {
String pattern = super.getPrefix();
String prefix = pattern.replace(HOSTNAME_VARIABLE, hostName);
prefix = prefix.replace("..", ".");
return prefix;
}
```
Hope this helps! | Create a Java method that does the following: "Override to return the prefix of the base class.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
public static <T extends TypesafeEnum<T>> Set<T> values(Class<T> clazz) {
Set<T> set = new HashSet<T>();
if (constants.containsKey(clazz)) {
set.addAll((Set<T>) constants.get(clazz));
}
return set;
}
```
Hope thi... | Create a Java method that does the following: "Returns a set of all values of the given class.". |
Of course, here is the Java code you requested:
```java
public int compareTo(E o) {
if (o.getClass() != getClass()) {
throw new ClassCastException();
}
return ordinal - TypesafeEnum.class.cast(o).ordinal;
}
```
Hope this helps! | Create a Java method that does the following: "Compares two Enum objects.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
public R proceed() throws Throwable {
try {
return (R) method().invoke(target, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
}
```
Hope this helps! | Create a Java method that does the following: "Proceeds the method.". |
Of course, here is the Java code you requested:
```java
public static String getProperty(String key, String def) {
return System.getProperty(key, def);
}
```
Hope this helps! | Create a Java method that does the following: "Get the value of the property with the given key.". |
Of course, here is the Java code you requested:
```java
public long getTime() {
long time = (isRunning()) ? total + System.nanoTime() - start : total;
return Math.round(time * getPrecision().value);
}
```
Hope this helps! | Create a Java method that does the following: "Get the time in nanoseconds.". |
Of course, here is the Java code you requested:
```java
public Events searchByState(String state) throws OpenStatesException {
return api.query(
new MethodMap("events"),
new ArgMap("state", state),
Events.class
);
}
```
Hope this helps! | Create a Java method that does the following: "Search by state". |
Of course, here is the Java code you requested:
```java
public Events search(String state, String type) throws OpenStatesException {
return api.query(
new MethodMap("events"),
new ArgMap("state", state, "type", type),
Events.class
);
}
```
Hope this helps! | Create a Java method that does the following: "Search for events in a state.". |
Of course, here is the Java code you requested:
```java
protected HttpClient buildClient() {
HttpClientBuilder builder = HttpClientBuilder.create().useSystemProperties().setConnectionManager(connManager);
if (!isBlank(username) && !isBlank(password)) {
final URI uri = URI.create(url);
... | Create a Java method that does the following: "Build the client.". |
Of course, here is the Java code you requested:
```java
private static String xpath( final String xml, final XPathExpression xpath )
throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
final DocumentBuilder builder = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder... | Create a Java method that does the following: "XPath.". |
Of course, here is the Java code you requested:
```java
public static <T extends Configuration> ConfigurationBinder<T> forClass(Class<T> klass, Binder binder) {
return new ConfigurationBinder<>(klass, binder);
}
```
Hope this helps! | Create a Java method that does the following: "Create a new instance of the class - level configuration binder.". |
Of course, here is the Java code you requested:
```java
public void toInstance(Config configuration) {
Preconditions.checkNotNull(configuration, "Configuration Instance cannot be null.");
if (annotationClass == null) {
binder.bind(configClass).toInstance(configuration);
} else {
... | Create a Java method that does the following: "Binds the class to the given configuration instance.". |
Of course, here is the Java code you requested:
```java
public void toFile(String fileName) {
Preconditions.checkNotNull(fileName, "File Name cannot be null.");
Config configuration = buildFromFile(fileName);
if (annotationClass == null) {
binder.bind(configClass).toInstance(confi... | Create a Java method that does the following: "Binds the configuration to the given file name.". |
Of course, here is the Java code you requested:
```java
private Config buildFromFile(String possibleFilename) {
File configFile = new File(possibleFilename);
Preconditions.checkArgument(configFile.exists(), "File must exist at: " + configFile.getAbsolutePath());
try {
return new Co... | Create a Java method that does the following: "Build a Config object from a file.". |
Of course, here is the Java code you requested:
```java
@Override
protected Class<?> load(String clazz, InputStream stream) {
// System.out.println(clazz);
try {
return Class.forName(clazz, true, classLoader);
} catch (Exception e) {
// System.out.println(e);
return null;
} catch (NoClassDefFoundErr... | Create a Java method that does the following: "Override this to load a class from the given stream.". |
Of course, here is the Java code you requested:
```java
@Override
public Set<Class<?>> resolveByName(final String name) throws IOException {
Matcher<Class<?>> matcher = new Matcher<Class<?>>() {
public boolean matches(Class<?> clazz) {
return clazz.getName().contains(name);
}
};
return resolve... | Create a Java method that does the following: "Resolves a set of classes by name.". |
Of course, here is the Java code you requested:
```java
@Override
public Set<Class<?>> resolveByAnnotation(
final Class<? extends Annotation> annotation) throws IOException {
Matcher<Class<?>> matcher = new Matcher<Class<?>>() {
public boolean matches(Class<?> clazz) {
Annotation[] annotations = clazz... | Create a Java method that does the following: "Resolves a set of classes by annotation.". |
Of course, here is the Java code you requested:
```java
@Override
public T mapRow(ResultSet rs, int rowNumber) throws SQLException {
Assert.state(this.mappedClass != null, "Mapped class was not specified");
T mappedObject;
try {
mappedObject = mappedClass.newInstance();
... | Create a Java method that does the following: "This method is called to map a single row of a ResultSet to a single object.". |
Of course, here is the Java code you requested:
```java
public static <T> RecordMapper<T> newInstance(Class<T> mappedClass) {
RecordMapper<T> newInstance = new RecordMapper<T>();
newInstance.setMappedClass(mappedClass);
return newInstance;
}
```
Hope this helps! | Create a Java method that does the following: "Create a new instance of the class mapper.". |
Of course, here is the Java code you requested:
```java
public static CodedMessage trace(final String code, final String... arguments) {
return new CodedMessage(code, CodedMessageLevel.TRACE, arguments);
}
```
Hope this helps! | Create a Java method that does the following: "Creates a new trace message.". |
Of course, here is the Java code you requested:
```java
public static CodedMessage debug(final String code, final String... arguments) {
return new CodedMessage(code, CodedMessageLevel.DEBUG, arguments);
}
```
Hope this helps! | Create a Java method that does the following: "Create a debug message.". |
Of course, here is the Java code you requested:
```java
public static FilterPattern newInstance(
EnumSet<DispatcherType> dispatcherTypes,
boolean matchAfter,
Iterable<String> patterns) {
return new FilterPattern(dispatcherTypes, matchAfter, ImmutableList.copyOf(patterns));
... | Create a Java method that does the following: "Create a new instance of the filter pattern class.". |
Of course, here is the Java code you requested:
```java
public static ConfigurationContext load(final ResourceRepository repository, final ResourceSelection selection)
throws ConfigurationException {
LOG.debug("从 {} 加载配置集合", selection);
Resource resource = repository.getResource(selection);
if (resource ==... | Create a Java method that does the following: "Load a configuration context from a resource repository.". |
Of course, here is the Java code you requested:
```java
public <T extends ReloadableConfigurationContainer> T getConfiguration(final Class<T> type, final ResourceSelection selection)
throws ConfigurationException {
Resource resource = getConfigurationResource(selection);
T container = (T) containerCache.get(r... | Create a Java method that does the following: "Gets the configuration object from the configuration file.". |
Of course, here is the Java code you requested:
```java
public static PagableQueryParams of(final Optional<String> optOffset, final Optional<Integer> optLimit)
{
return PagableQueryParams.of(optOffset, optLimit, Optional.<SortDirection> absent(),
Optional.<Boolean> absent());
}
```
Hope this helps! | Create a Java method that does the following: "Creates a new query object with the specified offset and limit.". |
Of course, here is the Java code you requested:
```java
public T proceed() throws Throwable {
try {
return constructor().newInstance(args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
}
```
Hope this helps! | Create a Java method that does the following: "Proceeds with the constructor.". |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Check if in given list of numbers, are any two numbers closer to each other than given threshold.
>>> hasCloseElements(Arrays.asList(1.0, 2.0, 3.0), 0.5)
false
>>> hasCloseElements(... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Check if in given list of numbers, are any two numbers closer to each other than given threshold.
>>> hasCloseElements(Arrays.asList(1.0, 2.0, 3.0), 0.5)
false
>>> hasCloseElements(Arrays.asList(1.0, 2.... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate gr... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (ea... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive floating point number, it can be decomposed into
and integer part (largest integer smaller than given number) and decimals
(leftover part always smaller than 1).
R... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a positive floating point number, it can be decomposed into
and integer part (largest integer smaller than given number) and decimals
(leftover part always smaller than 1).
Return the decimal par... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
You're given a list of deposit and withdrawal operations on a bank account that starts with
zero balance. Your task is to detect if at any point the balance of account fallls below zero, an... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
You're given a list of deposit and withdrawal operations on a bank account that starts with
zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
at that point f... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
For a given list of input numbers, calculate Mean Absolute Deviation
around the mean of this dataset.
Mean Absolute Deviation is the average absolute difference between each
element... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
For a given list of input numbers, calculate Mean Absolute Deviation
around the mean of this dataset.
Mean Absolute Deviation is the average absolute difference between each
element and a centerpoint (m... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
>>> intersperse(List.of(), 4)
[]
>>> intersperse(Arrays.asList(1, 2, 3), 4)
[1, 4, 2, ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
>>> intersperse(List.of(), 4)
[]
>>> intersperse(Arrays.asList(1, 2, 3), 4)
[1, 4, 2, 4, 3]
*/
pub... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum ... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Filter an input list of strings only for ones that contain given substring
>>> filterBySubstring(List.of(), "a")
[]
>>> filterBySubstring(Arrays.asList("abc", "bacd", "cde", "array"... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Filter an input list of strings only for ones that contain given substring
>>> filterBySubstring(List.of(), "a")
[]
>>> filterBySubstring(Arrays.asList("abc", "bacd", "cde", "array"), "a")
["abc", "... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
Empty sum should be equal to 0 and empty product should be equal to 1.
>>> ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
Empty sum should be equal to 0 and empty product should be equal to 1.
>>> sumProduct(List.of())... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
From a given list of integers, generate a list of rolling maximum element found until given moment
in the sequence.
>>> rollingMax(Arrays.asList(1, 2, 3, 2, 3, 4, 2))
[1, 2, 3, 3, 3... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
From a given list of integers, generate a list of rolling maximum element found until given moment
in the sequence.
>>> rollingMax(Arrays.asList(1, 2, 3, 2, 3, 4, 2))
[1, 2, 3, 3, 3, 4, 4]
*/
p... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Test if given string is a palindrome
*/
public boolean isPalindrome(String string) {
int i = 0;
int j = string.length() - 1;
while (i < j) {
if (str... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Test if given string is a palindrome
*/
public boolean isPalindrome(String string) {
int i = 0;
int j = string.length() - 1;
while (i < j) {
if (string.charAt(i)!= strin... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Input are two strings a and b consisting only of 1s and 0s.
Perform binary XOR on these inputs and return result also as a string.
>>> stringXor("010", "110")
"100"
*/
publ... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Input are two strings a and b consisting only of 1s and 0s.
Perform binary XOR on these inputs and return result also as a string.
>>> stringXor("010", "110")
"100"
*/
public String stringXor(S... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Out of list of strings, return the longest one. Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
>>> longest(List.of())
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Out of list of strings, return the longest one. Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
>>> longest(List.of())
Optional.empty
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return a greatest common divisor of two integers a and b
>>> greatestCommonDivisor(3, 5)
1
>>> greatestCommonDivisor(25, 15)
5
*/
public int greatestCommonDivisor(int a... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return a greatest common divisor of two integers a and b
>>> greatestCommonDivisor(3, 5)
1
>>> greatestCommonDivisor(25, 15)
5
*/
public int greatestCommonDivisor(int a, int b) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return list of all prefixes from shortest to longest of the input string
>>> allPrefixes("abc")
["a", "ab", "abc"]
*/
public List<String> allPrefixes(String string) {
List<Stri... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return list of all prefixes from shortest to longest of the input string
>>> allPrefixes("abc")
["a", "ab", "abc"]
*/
public List<String> allPrefixes(String string) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Return a string containing space-delimited numbers starting from 0 upto n inclusive.
>>> stringSequence(0)
"0"
>>> stringSequence(5)
"0 1 2 3 4 5"
*/
public String stri... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Return a string containing space-delimited numbers starting from 0 upto n inclusive.
>>> stringSequence(0)
"0"
>>> stringSequence(5)
"0 1 2 3 4 5"
*/
public String stringSequence(int n) {
|
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string, find out how many distinct characters (regardless of case) does it consist of
>>> countDistinctCharacters("xyzXYZ")
3
>>> countDistinctCharacters("Jerry")
4
... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given a string, find out how many distinct characters (regardless of case) does it consist of
>>> countDistinctCharacters("xyzXYZ")
3
>>> countDistinctCharacters("Jerry")
4
*/
public int co... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Input to this function is a string representing musical notes in a special ASCII format.
Your task is to parse this string and return list of integers corresponding to how many beats does e... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Input to this function is a string representing musical notes in a special ASCII format.
Your task is to parse this string and return list of integers corresponding to how many beats does each
not last.
... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Find how many times a given substring can be found in the original string. Count overlaping cases.
>>> howManyTimes("", "a")
0
>>> howManyTimes("aaa", "a")
3
>>> howManyTime... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Find how many times a given substring can be found in the original string. Count overlaping cases.
>>> howManyTimes("", "a")
0
>>> howManyTimes("aaa", "a")
3
>>> howManyTimes("aaaa", "aa")
3... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Input is a space-delimited string of numberals from 'zero' to 'nine'.
Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
Return the str... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Input is a space-delimited string of numberals from 'zero' to 'nine'.
Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
Return the string with numbers sort... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
From a supplied list of numbers (of length at least two) select and return two that are the closest to each
other and return them in order (smaller number, larger number).
>>> findClose... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
From a supplied list of numbers (of length at least two) select and return two that are the closest to each
other and return them in order (smaller number, larger number).
>>> findClosestElements(Arrays.asL... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Given list of numbers (of at least two elements), apply a linear transform to that list,
such that the smallest number will become 0 and the largest will become 1
>>> rescaleToUnit(Arra... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Given list of numbers (of at least two elements), apply a linear transform to that list,
such that the smallest number will become 0 and the largest will become 1
>>> rescaleToUnit(Arrays.asList(1.0, 2.0, 3... |
Of course, here is the Java code you requested:
```java
import java.util.*;
import java.lang.*;
class Solution {
/**
Filter given list of any values only for integers
>>> filter_integers(Arrays.asList('a', 3.14, 5))
[5]
>>> filter_integers(Arrays.asList(1, 2, 3, "abc", Map.of(), List.of()))
[1... | Make method to complete this class:
import java.util.*;
import java.lang.*;
class Solution {
/**
Filter given list of any values only for integers
>>> filter_integers(Arrays.asList('a', 3.14, 5))
[5]
>>> filter_integers(Arrays.asList(1, 2, 3, "abc", Map.of(), List.of()))
[1, 2, 3]
*/
p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.